Git Error – bad config file line 1 in .git/config

Last night, just before leaving the office, my development VM decided to crash unexpectedly.
Upon starting the machine the machine the following morning, and trying a git pull, I got the following error:

bad config file line 1 in .git/config

I CD’d into my .git directory, and opened up config in notepad
There was nothing in there, except for a load of whitespaces.
To fix this, I removed the whitespaces and saved the file.
Of course, this had lost my remote settings, but a quick git remote add origin <url> fixed this issue also

One response to “Git Error – bad config file line 1 in .git/config”

  1. Hao avatar

    Thanks! it worked immediately

Leave a Reply

Your email address will not be published. Required fields are marked *