Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bad git config file .git/config

Tags:

git

In my git repositiory, whenever I do any git commands like git status or git log, I get the error:
fatal: bad config file line 1 in .git/config
How do I rebuild that file or a new one?

like image 795
Spencer Avatar asked Mar 01 '12 00:03

Spencer


People also ask

Why git config is not working?

Try opening it and see do this file look like this. Try setting global config through command line by- git config --global user. email "[email protected]" It automatically set the . gitconfig in the directory it needed.

What should be in my Gitconfig file?

gitconfig) should really contain the settings that apply to ALL your repositories. Primarily things like user.name , user. email , core. editor , merge , and diff should be pretty consistently set.

Can I delete .gitconfig file?

gitconfig in unix platform. In Windows it will be stored in C:/users/<NAME>/. gitconfig. You can edit it manually by opening this files and deleting the fields which you are interested.

What is the .gitconfig file?

The git config command is a convenience function that is used to set Git configuration values on a global or local project level. These configuration levels correspond to . gitconfig text files. Executing git config will modify a configuration text file.


2 Answers

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] 
like image 43
Will Avatar answered Sep 26 '22 02:09

Will


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.

like image 175
Woody Hayday Avatar answered Sep 26 '22 02:09

Woody Hayday