Ephraim
Ephraim

Reputation: 797

git fetch/merge non-fast-forward changes?

Guess I've a feature branch (so not master) which I changed (e.g. amend a commit, rebased or so) so it has non-fast-forward commits waiting for fetch/merge.

How can I do this?
When I git fetch, git tells me, that it needed to force the update. So the nff commits are locally now. And here I'm stuck.

I tried to git rebase or git merge but nothing does it like I want it to.

Finally I did it like

git merge origin/branchname 

then I had a merge commit which logically does nothing.
And git reset --hard it back to the for last commit.

There must be a better way to do this... but how?

Upvotes: 3

Views: 1542

Answers (1)

VonC
VonC

Reputation: 1329592

If you have a merge origin/branchname which logically does nothing, that means the remote branch didn't have any commits of its own introducing new changes to your local branch:
The two branches are the same, even though your history has been rewritten.

So the simplest next step would be a git push --force origin branchname in order to replace the remote history of branchname by your local history.

Upvotes: 4

Related Questions