When trying to run git pull or git merge operations we get an error stating that the process will be aborted. If we try to force the process using –ff-only, it doesn’t work, we get the same error. In this post, we will talk about this issue and see what can be done if you get Fatal: Not possible to fast-forward, aborting GIT pull error.
Fix Fatal: Not possible to fast-forward, aborting GIT pull error
If you get Fatal: Not possible to fast-forward, aborting GIT pull error, follow the solutions mentioned below to resolve the issue.
- Pull the rebase
- Merge the changes from the master branch into a new branch
Let us talk about them in detail.
1] Pull with rebase
Instead of using a regular ‘git pull’ command, you can opt for the ‘git pull –rebase’ command. This command fetches the latest changes from the remote branch and then applies your local commits on top of the updated branch. This method helps in resolving diverging branch issues.
Following are the commands you need to run to pull with rebase.
First of all, run the following command to check out the problematic branched.
git checkout <branch-name>
Now, let us use the ‘git pull –rebase’ command to fetch remote branch changes and replay local commits on top of it.
git pull --rebase origin <branch-name>
In case, there are no conflicts, Git will voluntarily commit the changes on top of the updated branch. However, in case of conflicts, the rebase process will be halted and you will be notified about the conflicted files. You can resolve conflicts by using a merge tool or editing files manually. Use ‘git rebase –continue’ after resolving conflicts.
git rebase --continue
After the rebase process is finished, you can proceed to push your changes to the remote repository.
git push origin <branch-name>
This will do the trick for you.
2] Merge the changes from the master branch into a new branch
In case the local branch is included in the remote branch, one can pretty easily merge the changes from the master branch into a new branch. You can run the commands mentioned below to do the same.
First of all, run the following command.
git pull
Then, we need to run the command mentioned below to create a branch & check the origin/master head to a local branch.
git checkout -b new_branch origin/master
In case of merge conflicts, resolve them by editing the conflicting files. Then, stage and commit the changes. After creating a new branch, you can seamlessly merge any changes from the master branch into it.
Why is it not possible to fast forward aborting when trying to pull?
The Fatal error that says it is not possible to fast forward aborting when trying to pull signifies that Git is unable to merge the changes automatically. They are mainly caused by some conflicting changes between your local branch and the remote branch and/or the absence of the local branch in the remote branch.
Read: GitAtomic is a Git GUI Client for Windows systems
What is Fast forwardable in git?
In Git, a fast-forward is a type of merge that occurs when the target branch’s HEAD is directly reachable from the source branch’s HEAD. So, basically, no new commits have happened on the target branch since the source branch was created. Therefore, Git simply moves the HEAD pointer of the target branch to the HEAD of the source branch, without creating a new merge commit.
Also Read: Best Git GUI clients for Windows.