While building my portfolio and a small automation, I ran into a lot of Git errors. Most tutorials show the happy path, so here are the real errors I got, what they meant, and how I fixed each one.
A tip before you start: run one command at a time and read the result. I once pasted two commands on one line ( git diff --statgit diff | ... ) and got a confusing error.
1. fatal: bad config line 1 in file .git/config
Every Git command failed with this. My .git/config file was empty , so Git could not read it.
Fix: make a copy of your project folder first, then recreate the file with the basics:
[core] repositoryformatversion = 0 filemode = false bare = false logallrefupdates = true ignorecase = true [remote "origin"] url = https://github.com/your-username/your-repo.git fetch = +refs/heads/*:refs/remotes/origin/* [branch "main"] remote = origin merge = refs/heads/main
Enter fullscreen mode
Exit fullscreen mode
Then run git status . The first line must be [core] , with nothing above it.
2.…