【问题标题】:Installing git on Windows 10, unable to access .gitconfig在 Windows 10 上安装 git,无法访问 .gitconfig
【发布时间】:2016-11-23 16:57:11
【问题描述】:

我是 git 新手,我正在尝试从 here 安装 git 2.9.2。在安装(众多安装中的最后一个)中,我选择仅从 bash 运行它。我现在尝试设置它,我尝试的第一件事是设置我的名字

$ git config --global user.name "My Name"

但是在我执行这个之后,我得到:

fatal: unable to access 'C:\Program Files\Git\ C:\Windows\system32\config\systemprofile/.config/git/config': Invalid argument

假设我现在要克隆一个存储库。我插入如下内容:

git clone https://username@bitbucket.org/team/repo.git

但我明白了:

fatal: unable to access 'D:\TestRepo\ C:\Users\username/.config/git/config': Invalid argument

我以为.gitconfig文件应该在C:/Users/username目录下,但它试图定位C:\Users\username/.config/git/config,这似乎有点奇怪。我的 HOME 变量应该是 %USERPROFILE%。任何帮助表示赞赏。

【问题讨论】:

  • 好吧,试着按照 git 命令git config --global core.autocrlf = true 运行,然后告诉我你得到了什么输出。
  • 我得到'致命:无法访问C:\Program Files\Git\ C:\Users\username/.config/git/config: Invalid argument'
  • 您是否以管理员权限运行它? set HOMEPATH 输出什么?
  • 我做了,没有任何改变。 set HOMEPATH 按预期返回 HOMEPATH=\Users\username。我也尝试手动创建一个C:\Users\username/.config/git/config/.gitconfig 空文件,但没有任何改变。
  • 这很奇怪,尝试从系统中完全删除git并重新安装它

标签: windows git bash windows-10


【解决方案1】:

同样的问题。但是,如果我使用管理员级别的命令 shell(而不是 bash)运行,git config --global -l 可以工作。我的 git 版本 2.25.0.windows.1

我注意到在 Windows 的 System Info gui 中,System 的 env 变量的 HOME 条目为 %USERPROFILE%。但是,用户环境变量没有。我也添加了 HOME。

现在可以了。您会认为 System env 会填充那些不在 User 中的环境。也许还有其他事情发生。

【讨论】:

  • 你的 git 是什么? ;)
【解决方案2】:

您是否在尝试操作的文件夹上使用了git init

您还需要配置您的用户名和电子邮件到您的 github 帐户,以使其正常工作。

git config --global user.name "username"

git config --global user.email "email@gmail.com"

最后,如果您的名字中有空格,请记住将其转义。例如:“我的名字”=“我的姓名”

您是否设置了远程存储库?

git remote add origin https://github.com/rodoggx/yourRepository.git

【讨论】:

  • 问题没有提到 Github。请记住,Git 不是 Github。他们是两个完全不同的实体。如果有的话,问题会提到 BitBucket。
【解决方案3】:

好吧,我想我对基本事物缺乏了解让我看起来很愚蠢......

我只需要删除 HOME 环境变量,一切都像魅力一样。我什至不记得为什么我有一个 HOME 变量集(这不是 linux 的东西吗?)

无论如何,谢谢你们的时间。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-11-30
    • 2020-11-02
    • 2020-05-03
    • 2021-06-18
    • 2017-05-12
    • 2019-05-08
    • 2017-01-25
    相关资源
    最近更新 更多