Bad git config file .git/config

I know on some tutorials they ask you to put the below code, but what they actually mean is that they're the commands you type into the terminal: git config --global user.name "NewUser" git config --global user.email [email protected]

If you were modifying the file ( $ nano ~/.gitconfig ), you would put this into your file instead:

[user]
name = WilliamQLiu
email = [email protected]

My issue was related to my global config which Git resolved to $HOME/.gitconfig, however the underlying cause happened to be irrespective of the location.

> git config --global -l
fatal: bad config file line 1 in C:\Users\<user>/.gitconfig

I have a habit of symlink-ing the config files in my home directory to a nested Git repository for maintaining the files across my multiple development environments. It turns out that Cygwin's implementation of a symbolic link doesn't make much sense to Git running under Windows.

I changed the symbolic link to a hard link and somehow this works ok. I was able to verify this by opening the .gitconfig link within Windows; when using a symbolic link the file contained binary data however the hard-linked file contains the content as expected.


For those hitting into this issue (I believe it's due to crashing out git mid init?) in windows, if you have a recent backup of the config file from your git repo's .git/ folder you can fix it by replacing the existing with it (any ref's added since the copy will obviously need re-adding) - not at all ideal but better than loosing all the commits.


I had the same problem (Notepad++ showed only NULL characters in the file).

I managed to solve it by creating a new repo (in a seperate folder) with git init and copying .git/config over from there.

Remotes were missing after that, but everything worked after readding them manually.

Tags:

Git