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?
相关问题
- Why does recursive submodule update from github fa
- Extended message for commit via Visual Studio Code
- Emacs shell: save commit message
- Can I organize Git submodules in a flat hierarchy?
- Upload file > 25 MB on Github
相关文章
- 请教Git如何克隆本地库?
- GitHub:Enterprise post-receive hook
- Git Clone Fails: Server Certificate Verification F
- SSIS solution on GIT?
- Is there a version control system abstraction for
- ssh: Could not resolve hostname git: Name or servi
- Cannot commit changes with gitextensions
- git: retry if http request failed
I had the same issue for my Android project. So I just did following in Android Studio: File -> Invalidate Cache and Restart. It helped me.
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 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 newuser@example.com
If you were modifying the file (
$ nano ~/.gitconfig
), you would put this into your file instead:The best they can do is copy all their files in another route except the folder .git then make clone of the last commit that managed to upload and paste the files that moved to the other route so that they are overwrite and allow the new commit.
This can be happen if you manually edit .gitconfig file . in the C:\Users\.gitconfig (you can edit it using Notepad++ ) open it and check these lines.
you can change those line. if you add wrong line to editor variable it can lead to an error. simply you can delete this line. but make sure to get back up of it. Or you can check right code/path to connect with your text editor and replace it with new working code/path.
Then save it. (this can be more helpful to android studio users)
I had the same problem right after initial installation.
"fatal: bad config line 1 in file C:\ProgramData/Git/config"
I opened notepad as administrator, navigated to the file listed in the error message. The file was also blank but it had spaces/tabs so I deleted them saved the file. And now it works