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

Greg Foster
Greg Foster
Graphite software engineer

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".

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.

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:

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:

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:

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:

git add <resolved-file>

Then, complete the merge:

git commit

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

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

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.
Get started

Give your PR workflow
an upgrade today

Stack easier | Ship smaller | Review quicker

Or install our CLI.
Product Screenshot 1
Product Screenshot 2