Data report"State of code review 2024" is now liveRead the full report

Troubleshooting the "git not possible to fast-forward aborting" error

Greg Foster
Greg Foster
Graphite software engineer


Note

This guide explains this concept in vanilla Git. For Graphite documentation, see our CLI docs.


This guide will explain what this error means, how it occurs, and provide a step-by-step approach to resolve it.

The "git not possible to fast-forward aborting" error occurs when Git cannot apply changes from the remote repository to your local branch without merging. Fast-forwarding is a process where the head of your local branch is moved to the head of the remote branch, provided that the remote branch is ahead of your local branch and there are no divergent changes.

If your local branch has diverged from the remote branch (i.e., there are commits in your local branch that the remote branch does not have), Git cannot simply move the pointer forward; this results in the error "git not possible to fast-forward aborting".

Stop wrestling with Git commands

The Graphite CLI takes all the pain out of Git, allowing you to ship faster and stop Googling Git commands.

Learn more

This error typically occurs in the following scenarios:

  1. Local and remote branches have diverged: You've made commits to your local branch that are not in the remote branch, and there are also new commits on the remote branch that you do not have locally.

  2. Non-linear history due to rebasing or squashing commits: If the history of the remote branch was rewritten (e.g., using git rebase or git commit --amend) after you had already pulled from it, your local branch will not be able to fast-forward.

Here’s how to resolve the "git not possible to fast-forward aborting" error, with detailed commands:

Before making any changes, ensure your local repository is up to date with the remote repository's information.

Terminal
git fetch origin

This command fetches all the latest changes from the remote but doesn’t merge them into your local branches.

Compare your local branch with the remote branch:

Terminal
git status

This command will help you understand whether your local branch is behind, ahead, or has diverged from the remote branch.

If your branch has diverged or is behind, inspect the differences:

Terminal
git log --oneline --graph --decorate --all

This command provides a visual representation of the commit history across all branches, helping you see where the branches diverged.

To resolve the fast-forward issue, you will need to merge the remote branch into your local branch:

Terminal
git merge origin/<branch-name>

Replace <branch-name> with the name of your branch. This command tries to merge changes from the remote branch into your local branch. If there are conflicts, Git will pause the merge and ask you to resolve them.

If the merge results in conflicts, Git will tell you which files need attention. Open these files and make the necessary changes. After resolving conflicts, mark the files as resolved with git add:

Terminal
git add <resolved-file>

Then, complete the merge:

Terminal
git commit

Git may auto-generate a commit message for the merge. You can modify it if needed.

The best engineers use Graphite to simplify Git

Engineers at Vercel, Snowflake & The Browser Company are shipping faster and staying unblocked with Graphite.

Git started for free

Once your branch has successfully merged with the remote branch, push your changes to update the remote repository:

Terminal
git push origin <branch-name>

For further reading on fast-forward merges see the official Git documentation.

Stay unblocked. Ship faster.
Experience the new developer workflow - create, review, and merge code continuously. Get started with one command.
Learn more

Give your PR workflow
an upgrade today

Stack easier | Ship smaller | Review quicker

Or install our CLI.
Product Screenshot 1
Product Screenshot 2