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?
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.
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.
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.
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.
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]
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With