我的 Git 安装总是指向错误的目录.为什么? [英] My Git installation always refers to the wrong directory. Why?

查看:20
本文介绍了我的 Git 安装总是指向错误的目录.为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的 Windows8 机器上安装并重新安装了 Git 多次.至于我为什么这样做,这是一个很长的故事.一旦我将它安装在 C:Git,现在我将它安装在 C:Program Files (x86)Git,现在我遇到了 Git 配置问题.我的 Git 配置无法将安全凭证写入 Git 配置文件,因为它认为它们位于不再存在的位置 (C:Git).

I installed and re-installed Git on my Windows8 machine multiple times. It's a long story as to why I did that. Once I installed it at C:Git and now I have it installed at C:Program Files (x86)Git and now I am having Git configuration problems. My Git configuration is unable to write security credentials to Git configuration files because it thinks they are in a location that no longer exists (C:Git).

因此,我总是求助于使用 GitHub GUI,但这不适用于 Heroku.所以现在我需要帮助.

Because of this, I always resort to using the GitHub GUI, but that wont work with Heroku. So now I need help.

例如,当我尝试将代码推送到 Heroku 时,我得到:

For example, when trying to push code to Heroku I get:

C:IntelliJ IDEA 12.1.4workspacesignup-sheet>git remote -v
heroku  git@heroku.com:signup-sheet.git (fetch)
heroku  git@heroku.com:signup-sheet.git (push)
origin  https://github.com/djangofan/signup-sheet.git (fetch)
origin  https://github.com/djangofan/signup-sheet.git (push)
C:IntelliJ IDEA 12.1.4workspacesignup-sheet>git push heroku master
Could not create directory '/c/Git/.ssh'.
The authenticity of host 'heroku.com (__.__.__.156)' can't be established.
RSA key fingerprint is 8b:48:5e:00:0e:00:16:00:32:00:87:0c:00:c8:60:ad.
Are you sure you want to continue connecting (yes/no)? yes
Failed to add the host to the list of known hosts (/c/Git/.ssh/known_hosts).
Permission denied (publickey).
fatal: Could not read from remote repository.

还有,

C:IntelliJ IDEA 12.1.4workspacesignup-sheet>git config --global user.email "djangofan@gmail.com"
error: could not lock config file C:Git/.gitconfig: No such file or directory

推荐答案

这与环境变量 HOME 的值相关联.

This is linked to the value of the environment variable HOME.

  • make sure you don't have one defined in your windows session.
  • use the git-cmd.bat which comes with your msysgit (obsolete since early 2015)
    use the git-cmd.exe which comes with your git-for-windows:
    it will set HOME to the right value, and will be able to look for/ or create %HOME%/.ssh and other config files which reside in %HOME% directory.

使用旧的 msysgit,git-cmd.bat 包含:

With the old msysgit, that git-cmd.bat contains:

@if not exist "%HOME%" @set HOME=%HOMEDRIVE%%HOMEPATH%
@if not exist "%HOME%" @set HOME=%USERPROFILE%

使用新的 git-for-windows,git.exe 使用以下内容构建:

With the new git-for-windows, the git.exe is build with:

--cd-to-home"; WorkingDir: %HOMEDRIVE%%HOMEPATH%

在这两种情况下,HOME 默认设置为 %HOMEDRIVE%%HOMEPATH%.

In both cases, HOME is set to, by default, %HOMEDRIVE%%HOMEPATH%.

这篇关于我的 Git 安装总是指向错误的目录.为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆