2017-10-05 179 views
1

我安装了Cygwin和TortoiseGit。我通过ssh-key-gen -t rsa创建了ssh-key,并在我的GitHub页面注册了公钥。当在gitbash终端,它的工作,但Cygwin终端失败。如何在Cygwin终端中指定git路径?

// Cygwin 
$ git pull 
Permission denied (publickey). 
fatal: Could not read from remote repository. 

Please make sure you have the correct access rights 
and the repository exists. 

我注意到他们使用不同的git。那么,如何在Cygwin中指定git路径?我的操作系统是Windows 10.

// Cygwin 
$ where git 
C:\Program Files\Git\cmd\git.exe 
$ which git 
/cygdrive/c/Program Files/Git/cmd/git 

// gitbash (MINGW64) 
$ where git 
C:\Program Files\Git\mingw64\bin\git.exe 
C:\Program Files\Git\cmd\git.exe 
$ which git 
/mingw64/bin/git 
+0

与cygwin使用它的git。它将更容易管理由cygwin ssh-key-gen – matzeri

回答

2

git路径本身对于ssh并不重要。

要紧的是$HOME,因为git的(任何GIT)将在$HOME/.ssh

仔细检查这两种情况下你echo $HOME输出,并检查ssh -Tv [email protected]结果(替换用户搜索公共/私人SSH密钥并在服务器打开时看到ssh URL的开头git remote -v

另外,Cygwin has its own Git package as I explain here
it needs a .bash_profile as a setting

+0

创建的ssh-key,正确设置'$ HOME',并通过'ssh -Tv'成功验证ssh认证。我仍然认为这个git设置不正确。 – jef

+0

@jef你可以设置环境变量'GIT_SSH_COMMAND'(在'CMD'上设置'',在bash上'export')为'ssh -v',并且在两种情况下都可以看到'git pull'上发生了什么?应该有区别。 – VonC

+0

@jef而你没有提到你使用的是密码保护的ssh私钥(https://stackoverflow.com/q/46627127/6309) – VonC