Installing git on Windows 10, unable to access .gitconfig

末鹿安然 提交于 2020-02-02 06:00:16

问题


I'm new to git, and i'm trying to install git 2.9.2 from here. In the installation (the last of the many) i chose to run it from bash only. I now try to set it up, and the first thing i try is to set my name with

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

But after i execute this, i get:

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

Let's say that i now want to clone a repository. I insert something like:

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

But i get:

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

I thought that the .gitconfig file should be inside the C:/Users/username directory, but it tries to locate C:\Users\username/.config/git/config, which seems a little weird. My HOME variable is %USERPROFILE%, as it should. Any help appreciated.


回答1:


Did you use git init on the folder you are trying to operate from? Also you need to configure your username and the email to your github account for it to work properly.

git config --global user.name "username"

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

also if you have a space in your name please remember to filter it. ex: "my name" = "my\ name"

did you set up your remote repository? git remote add origin https://github.com/rodoggx/yourRepository.git




回答2:


Same issue. But if I run with command shell (not bash) with Admin level, git config --global -l works. My git version 2.20.1.windows.1

I noticed that in the System Info gui of Windows, the env variables for System had a HOME entry of %USERPROFILE%. But, the User env variables did not. I added HOME to that too.

Now it works. You'd think the System env would fill in for those not in User. Maybe something else is going on. My git is:




回答3:


Ok i guess my lack of knowledge over basic things made me look stupid...

I just had to delete the HOME environmental variable and all worked like charm. I don't even remember why i had a HOME variable set (isn't that a linux thing?)

Anyway thank you for your time guys.



来源:https://stackoverflow.com/questions/38481534/installing-git-on-windows-10-unable-to-access-gitconfig

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!