The editor closed without a message, so Git cancelled the commit. Nothing was saved. It also happens every time when core.editor is plain code without --wait: VS Code opens, but Git doesn't wait for you.
How to fix it
Run git config --global --get core.editor. If it doesn't print code --wait, set it again with the quotes: git config --global core.editor "code --wait". Or commit with -m "message".
fatal: pathspec '.gitignore' did not match any files
fatal: pathspec '.gitignore' did not match any files
What it means
There's no file with that name in this folder. You may be in the wrong folder, or the file got another name, such as .gitignore.txt (Explorer hides the .txt).
How to fix it
Check where you are and list hidden files with Get-ChildItem -Force. Create the file with code .gitignore.
You asked for a fast-forward only (--ff-only, or the pull.ff=only setting), but both branches have new commits.
How to fix it
Merge without --ff-only to create a merge commit, or rebase first (Day 10). When it's a fork's main that has moved away from upstream, don't merge: save your commits on a branch (git branch my-work), then git reset --hard upstream/main (see Bonus 3).
The two branches have no commit in common. Typically GitHub made its own first commit (a README) and your laptop has another.
How to fix it
For a brand-new GitHub repo, delete it and create it again empty. Or join them once: git pull --no-rebase --allow-unrelated-histories origin main, then git push -u origin main.
git add found another repository inside this one. Only a pointer gets added, which nobody can clone.
How to fix it
Take it out again with git rm -r -f --cached playground (it only unstages; the folder stays on disk), make sure .gitignore contains playground/, then commit.
error: The branch 'docs/contributing-tips' is not fully merged.
error: The branch 'docs/contributing-tips' is not fully merged.
What it means
The branch's own commits aren't in the branch you're on. Right after a Squash and merge, a Rebase and merge or a cherry-pick this is expected: main only has copies of them.
How to fix it
Check the work is safe: the PR shows Merged and you ran git pull on main, or a tag such as v1.2.1 points at the commit. Then git branch -D docs/contributing-tips.
--force-with-lease refused: someone pushed to that branch after your last fetch. Nothing was overwritten.
How to fix it
git fetch, then look with git log --format="%h %an %s" HEAD..origin/feature/export-csv. Bring the new commit in (git cherry-pick <id>), then git push --force-with-lease again.
! [rejected] feature/export-csv -> feature/export-csv (remote ref updated since checkout)
! [rejected] feature/export-csv -> feature/export-csv (remote ref updated since checkout)
What it means
--force-if-includes refused: a fetch brought in a commit that isn't part of your branch yet, so forcing would erase it.
How to fix it
Look at the new commit with git log HEAD..origin/feature/export-csv and bring it into your branch (git cherry-pick <id>). Then push with git push --force-with-lease alone: --force-if-includes doesn't count a cherry-picked copy and would refuse again.
error: could not apply 1e4386a... Document the CSV export
error: could not apply 1e4386a... Document the CSV export
What it means
A rebase (or a cherry-pick) stopped because replaying this commit caused a conflict. The hint lines under it say which one.
How to fix it
Fix the conflicted files (git status lists them), git add them, run the tests, then git rebase --continue (or git cherry-pick --continue). To go back instead: git rebase --abort.
The following paths are ignored by one of your .gitignore files:
The following paths are ignored by one of your .gitignore files:
What it means
You asked Git to add a file that a .gitignore rule excludes. Git lists the paths on the next lines and suggests -f.
How to fix it
Usually nothing: the rule is doing its job. If the file really belongs in Git, fix the rule (git check-ignore -v <path> shows which one) or use git add -f <path>.
! [remote rejected] main -> main (pre-receive hook declined)
! [remote rejected] main -> main (pre-receive hook declined)
What it means
A check on the server refused your whole push. The remote: lines just above say why: for example GH001 (a file is too big) or GH006 (a protected branch).
How to fix it
Read the remote: error: lines and fix that cause. For GH001, take the file out of the commits you haven't pushed yet, ignore it, and push again.
GitHub already has a tag called v1.0.1 that points somewhere else. Git's hint adds Updates were rejected because the tag already exists in the remote.
How to fix it
Don't force it: people may use the published tag. git ls-remote --tags origin lists the tags GitHub has. Delete your own copy with git tag -d v1.0.1, and release your change as the next version.
hint: Updates were rejected because the tip of your current branch is behind
hint: Updates were rejected because the tip of your current branch is behind
What it means
Your branch doesn't contain the newest commits of its copy on GitHub. Right after you rewrote your own pushed branch (rebase or amend), those are simply your old commits.
How to fix it
If you just rewrote a branch that is yours alone: git push --force-with-lease, and don't git pull, which brings the old commits back in. If you rewrote nothing, a teammate pushed first: git pull --rebase, then push.
warning: in the working copy of 'transform.py', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'transform.py', LF will be replaced by CRLF the next time Git touches it
What it means
Windows line-ending conversion is on (core.autocrlf=true). Git is telling you it will store the file with Linux-style line endings and give you Windows ones.
How to fix it
Nothing to do: it's harmless. A .gitattributes file with * text=auto makes this consistent for the whole team.
ScriptBlock should only be specified as a value of the Command parameter.
ScriptBlock should only be specified as a value of the Command parameter.
What it means
Same PowerShell problem: an unquoted {…} in HEAD@{1} or stash@{0} was read as PowerShell code. PowerShell prints this one itself when the command also has a -c option, as in git switch -c rescue/my-work HEAD@{1}. Git never ran.
fatal: ambiguous argument 'HEAD@': unknown revision or path not in the working tree.
fatal: ambiguous argument 'HEAD@': unknown revision or path not in the working tree.
What it means
The same PowerShell problem again, with git show, git log or git diff: the unquoted {1} of HEAD@{1} was read as PowerShell code, so Git only received HEAD@.
GitHub didn't accept your SSH key: it isn't added to your account, or the wrong key is being used.
How to fix it
ssh -T git@github.com to test. Add your public key (~/.ssh/id_ed25519.pub) in GitHub settings under SSH keys. Or use the HTTPS URL and sign in through the browser.
fatal: Authentication failed for 'https://github.com/acme/invoice-pipeline.git/'
fatal: Authentication failed for 'https://github.com/acme/invoice-pipeline.git/'
What it means
GitHub rejected the credentials. Account passwords don't work for Git any more.
How to fix it
Let Git Credential Manager sign you in through the browser. If an old saved credential is stuck, remove the git:https://github.com entry in Windows Credential Manager and try again.
error: cannot pull with rebase: You have unstaged changes.
error: cannot pull with rebase: You have unstaged changes.
What it means
A pull that rebases needs a working folder without uncommitted changes. That's git pull --rebase, and also plain git pull once pull.rebase is true (a course setting from Day 1).
How to fix it
Commit or stash first (git stash, git pull --rebase, git stash pop), or use git pull --rebase --autostash.
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
What it means
A file in your push is larger than GitHub's 100 MB limit.
How to fix it
Remove the file from the commits you're pushing, add it to .gitignore, and push again. See Rescue › My push was rejected › A file is too big for GitHub.