Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not possible to fast-forward even with no changes

Tags:

git

I ended up in a weird git state. I want to pull from server, only fast forwards.

However, even when there were no changes, git keeps telling me "not possible fast-forward".

$ git pull -v --ff-only
From github.com:username/repo
 = [up to date]      branch    -> origin/branch
 = [up to date]      branch2    -> origin/branch2
 = [up to date]      branch3    -> origin/branch3
fatal: Not possible to fast-forward, aborting.

How do I tell git to tell me more information about this "non-possibility" of fast-forward? I canot be more verbose...

like image 432
Karel Bílek Avatar asked Mar 10 '15 20:03

Karel Bílek


People also ask

Why is it fatal not possible to fast forward abortion?

fatal: Not possible to fast-forward, aborting. means that you've told Git to use --ff-only for the merge that occurs as the second step of git pull 1 and that this merge cannot be done as a fast-forward.

How do you resolve a non-Fast-Forward rejection?

After the git fetch I recommend examining the situation with gitk --all. Git push rejected non-fast-forward means, this error is faced when git cannot commit your changes to the remote repository. This may happen because your commit was lost or if someone else is trying to push to the same branch as you.

What does no fast forward mean?

Using the --no-ff parameter prevents the Git merge command from performing a fast-forward merge when Git detects that the current HEAD is an ancestor of the commit that you're trying to merge.

What is no fast forward in git?

A non-fast-forward merge is a merge where the main branch had intervening changes between the branch point and the merge back to the main branch. In this case, a user can simulate a fast-forward by rebasing rather than merging. Rebasing works by abandoning some commits and creating new ones.


2 Answers

Your commits on your 'develop' branch do not match the commits on your 'origin' branch. Do this:

git pull origin develop --rebase
like image 175
j2emanue Avatar answered Sep 30 '22 11:09

j2emanue


This happens when (a) you committed something on that branch earlier, or (b) the history on the remote server changed in a non-standard way (this shouldn't normally happen but repository owners sometimes don't play by the rules).

For the following I'm assuming you're on foo and the upstream branch is origin/foo.

  • Use git log ..origin/foo to see what commits are new on the remote side.
  • Use git log origin/foo.. to see what commits exist on your side that don't exist on the remote side (this will show you any commits that are preventing fast-forwarding).
  • If you conclude that those commits are not needed or already present in a different form on the remote side, git reset --hard origin/foo to force your branch to become equal to the remote one (this will destroy all uncommitted changes and any commits not contained in remote/foo will become unreachable).
like image 45
Jan Krüger Avatar answered Sep 30 '22 10:09

Jan Krüger