Karel Bílek Karel Bílek - 2 months ago 24
Git Question

Not possible to fast-forward even with no changes

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

Answer

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).
Comments