背景说明: 我搭建了一个git服务器在linux客户端推送文件没问题。
那么问题来了: 对于在客户端主机是window安装机器 如何使用 git bash 克隆服务器的仓库呢? 其实,步骤也linux客户端一样的。具体如下
1、 在windows上安装好了git bash--(下载地址:windows下面可以使用https://git-for-windows.github.io/) 就直接在某个目录右键,打开git bash窗口: 执行命令ssh-keygen生成密匙对。
$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/Administrator/.ssh/id_rsa):
/c/Users/Administrator/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/Administrator/.ssh/id_rsa. ----即生成的私匙路径
Your public key has been saved in /c/Users/Administrator/.ssh/id_rsa.pub.----即生成的公匙路径
The key fingerprint is:
SHA256:nt5MF18BObTsMGigF/PYjqXPYTH++oAHwQ6c87D3xBs Administrator@lkq-PC
The key's randomart image is:
+---[RSA 2048]----+
| + .o. |
| . + B . .oo |
| B = O o o.. |
| O X o + .|
| . BSE .. .|
| ..O.= o . |
| .oB... . |
| ..+o. |
| ..+. |
+----[SHA256]-----+
Administrator@lkq-PC MINGW32 /e/test/gitfile
2、 将上面生成的 /c/Users/Administrator/.ssh/id_rsa.pub.----即生成的公匙内容复制到git 服务器的authorized_keys里面去。
接着,用命令 git clone git@192.168.190.130:/data/gitroot/sample.git 即可克隆下来。
Administrator@lkq-PC MINGW32 /e/test/gitfile
$ git clone git@192.168.190.130:/data/gitroot/sample.git
Cloning into 'sample'...
git@192.168.190.130's password:---------------这里需要输入下git用户的密码,我们需要去服务器上设置下git用户的密码即可
remote: Counting objects: 6, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 6 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (6/6), done.
Checking connectivity... done.
Administrator@lkq-PC MINGW32 /e/test/gitfile
编辑回复