Git fixes,
in plain words.
The exact error message, what it means, and the shortest safe fix.
Pick your error
10 fixesfatal: not a git repository
Wrong folder, no git init, or a deleted .git folder. How to tell which.
2Undo the last commit, keep the changes
reset --soft, mixed and --hard, what each keeps, and what to do after a push.
3git init with a main branch, not master
-b main, init.defaultBranch, and renaming master to main.
4git add . is not adding my files
Five real causes: .gitignore, wrong folder, embedded repo, empty folder, typo.
5fatal: remote origin already exists.
Check with git remote -v, then set-url, rename or remove.
6fatal: Authentication failed (GitHub)
Passwords no longer work over HTTPS. Token, GitHub CLI, credential manager or SSH.
7Merge conflict: what the markers mean
Open the file, choose what stays, delete the markers, then add and commit.
8You are in 'detached HEAD' state
Not an error. HEAD points at a commit, not a branch. How to look around, and how to keep work.
9! [rejected] ... failed to push some refs
The remote has commits you do not. Pull them in, then push. Why not to force it.
10Permission denied (publickey)
GitHub does not know your SSH key. Check the key, the agent and the account, in that order.
Git messages on these pages come from real Git output or the official GitHub and Git docs, and each page says which. Want to learn the ideas behind them? Start the course, or try commands safely in the practice terminal.