Overview:
$ git pull
... time passes ...
$ git checkout topic # remote topic
$ git checkout master
$ git merge topic
$ git push
non-fast-forward updates were rejected
$ git pull
merge by rebase
$ git push
The result is that the file changes are pushed but the reference back to the topic branch has been lost. (On github, this results in a pull request not closing.) It also makes the graph look odd in that topic branch is not shown to be merged into master.
The trigger for causing this to happen is a pull after the merge that requires a merge. That is, master was changed during the topic merge.
The setting for pull is to always use pull –rebase.
As a further side affect a tag placed on the merge point was kind of lost. The tag was never pushed (although it was requested).
We were able to fix the graph by re-merging the topic branch.
How can we avoid this in the future? What is it that causes this problem? It doesn’t feel like we’ve done anything incorrectly.
Thanks!
ps
The config is set to only pull/push the current branch.
The “fix” is to not use
pull --rebase– rebasing is what is losing your history. The entire point of merging instead of rebasing is to keep the separate branch history around.git pullis normally the equivalent ofgit fetch+git merge.git pull --rebaseisgit fetch+git rebase.The former preserves history links; the latter creates entirely new commits. (Is there a particular reason you have
git pullset to always rebase?)You can also do a
git pullonmasterbefore you merge intopicto try to ensure thatmasteris up to date (so that the merge won’t result in a non-fast-forward history).