/errors/git/not-possible-to-fast-forward
fatal: Not possible to fast-forward, aborting.
verified onenvironmentlocal · linux 6.18.44-fc-v140 x64 · GNU bash 5.2.21 · git version 2.43.0updated
- tool
- Git
- exit code
- 128
- versions
- Git 2.x
- os
- linux, macos, windows
fatal: Not possible to fast-forward, aborting. means your branch and its upstream both have commits the other lacks, so Git cannot move the branch pointer forward. The pull was restricted to fast-forward (--ff-only or pull.ff = only). Choose how to combine the histories: rebase or merge.
Reproduce it
A bare-bones setup: a remote with one commit, a clone, then one new commit on each side.
git init -q -b main up
git -C up commit -q --allow-empty -m base
git clone -q up cl
git -C up commit -q --allow-empty -m remote-change
git -C cl commit -q --allow-empty -m local-change
cd cl
git pull --ff-only 2>&1 | grep '^fatal'
git pull --rebase -q
git log --onelineOutput
fatal: Not possible to fast-forward, aborting. 30c0a8b local-change 44e9f9c remote-change 5d8392b base
Choose a fix
| Command | Result |
|---|---|
git pull --rebase | Linear history; your commits get new hashes. |
git pull --no-rebase | A merge commit joins both lines. |
git reset --hard @{u} | Discards local commits and changes. Not undoable easily. |
Check what differs first with git log --oneline --left-right HEAD...@{u}. To make rebase the default, run git config --global pull.rebase true.
Sources
Related pages
glossary · gitWhat is a fast-forward merge in Git?A fast-forward merge moves the branch pointer to the other branch's commit when nothing diverged, so no merge commit is made. What --no-ff and --ff-only do.errors · giterror: failed to push some refs (rejected, fetch first)git push is rejected with failed to push some refs when the remote branch has commits you do not have. Pull or fetch and rebase first, then push again safely.compare · gitgit merge vs git rebase: differences and when to use eachgit merge joins histories with a merge commit and keeps them as they happened; git rebase replays commits on a new base for a linear history with new hashes.errors · giterror: cannot pull with rebase: You have unstaged changes.git pull --rebase refuses to run while tracked files have uncommitted changes. Commit or stash them first, or use git pull --rebase --autostash to do both.