"无法将主机添加到已知主机列表中#34; Windows提示

时间:2014-05-31 21:46:04

标签: windows git command-line

我想尝试在常规Windows提示符中使用git,而不是在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

2 个答案:

答案 0 :(得分:4)

首先,使用msysgit 1.9.2进行测试,当安装过程中选择git cmd.exe时可以使用git clone命令时(其他选择是,只能在git bash下使用,或者使所有MSYS命令在cmd.exe下可用),HOME cmd.exe 提示符下工作。

ssh客户端使用.ssh/环境变量来查找HOME目录,但 git 应该处理所有丑陋的细节。您应该在正常的Windows环境中定义echo %HOME%,因此如果 cmd.exe 提示中的HOME打印路径,请编辑操作系统环境变量并删除C:UsersUsername

如果仍然无法解决问题,卸载和安装最新版本可能有所帮助。


最后,你有像echo C:\Users\Username echo 'C:\Users\Username' 这样的路径,这可能意味着你在某个地方缺少引号。在 git bash 中,尝试以下两个命令来查看:

{{1}}

答案 1 :(得分:1)

确保您为每个git-cmd.bat附带的 Git For Windows msysgit release 键入cmd会话。

这会将您的HOME设置为%USERPROFILE%,其应为C:\Users\Username 但请确保您没有使用不正确的值定义的环境变量HOME:如果是这种情况,请取消设置。