在Windows 10上安装git,无法访问.gitconfig

时间:2016-07-20 12:37:52

标签: windows git bash windows-10

我是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%,应该如此。任何帮助表示赞赏。

3 个答案:

答案 0 :(得分:1)

您是否在尝试操作的文件夹上使用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

答案 1 :(得分:0)

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

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

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

答案 2 :(得分:0)

相同的问题。但是,如果我使用具有管理员级别的命令外壳程序(而不是bash)运行,则git config --global -l可以工作。我的git版本 2.20.1.windows.1

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

现在可以使用了。您可能会认为System env可以代替User中的用户。也许正在发生其他事情。我的git是:

相关问题