我想尝试使用 git
在我的常规 Windows 提示符中而不是在 Git Bash 中。仅仅是因为我可以使用 IntelliJ 提供的终端。我认为这是一个 1 分钟的修复,但我想不是。
当我尝试 git pull origin <branch>
我收到以下错误消息:
C:\Users\Username\Documents\Bitbucket\java-project>git pull
Could not create directory '/c/Username/.ssh'.
The authenticity of host 'bitbucket.org (131.103.20.167)' can't be established.
RSA key fingerprint is 12:8c:1b:f2:6d:14:6b:5c:3b:ec:aa:46:46:xy:7c:40.
Are you sure you want to continue connecting (yes/no)? yes
Failed to add the host to the list of known hosts (/c/Username/.ssh/known_hosts).
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
我已经对现有设置了权限.ssh
文件夹,以便所有用户、管理员和 SYSTEM 都具有完全访问权限。所以应该没问题。
我还尝试以管理员身份运行提示以查看是否是问题所在,但也不是这种情况。
我现在注意到的是它说:Could not create directory '/c/Username/.ssh'.
.然而,我的.ssh
目录位于 C:\Users\Username\.ssh
.那时我可能需要更改我的配置。
Git 版本: 1.9.0.msysgit.0 Windows 版本:Windows 8.1
最佳答案
首先,使用 msysgit 1.9.2 进行测试,当在安装过程中选择使 cmd.exe
中的 git
命令可用时(其他选择是,使它仅在 git bash 下可用,或者使所有 MSYS 命令在 cmd.exe 下可用),git clone
从 cmd.exe 提示符下运行。
ssh 客户端使用 HOME
环境变量来查找 .ssh/
目录,但是 git 应该处理所有丑陋的细节。您应该不在正常的 Windows 环境中定义 HOME
,因此如果 cmd.exe 中的 echo %HOME%
提示打印路径,编辑操作系统环境变量并删除 HOME
。
如果这不能解决问题,卸载并安装最新版本可能会有所帮助。
最后,您有像 C:UsersUsername
这样的路径,这可能意味着您在某处缺少引号。在 git bash 中,尝试这两个命令以查看:
echo C:\Users\Username
echo 'C:\Users\Username'
关于windows - "Failed to add the host to the list of known hosts" Windows 提示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23974739/