threads / discuss / 28617

Pull --rebase looses merge information

Subject: Pull --rebase looses merge information

## tl;dr

3 messages between Oct 6, 2011 and Oct 7, 2011.

replies: 2people: 3as markdown or json

Duane Murphy· Oct 6, 2011, 19:21 UTC · lore
Here is the synopsis:
$ git checkout master
$ 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; implied by config
$ git push
The result of this process is that the file changes are pushed but the reference back to the topic branch has been lost. This makes it appear as though the topic branch has not been merged properly.
The trigger appears to be the pull (with rebase) that occurs after the merge and before the push. This of course is caused by the repo being out of sync from the point when the merge was started. That window of time can be shortened but it can never be zero.
The problem is fixed by merging again, but it's difficult to notice that this problem has actually occurred.
It has been noted that the problem is that we are using rebase on pull. We set our configurations to always rebase on a pull from a remote branch. This makes sense as it prevents artificial merges and unusual modifications to the history with respect to the shared repository. That is, if I'm working on merging changes into a remote branch and some one beats me, my merge should be after his, not before.
I would hope that a rebase operates mostly like a merge (understanding that rebase is different). I would not expect the merge information (ie the source branch of the merge) to be lost just because of a rebase.
Is there a bug here? Is there some way to avoid this situation without sacrificing the benefits of pull --rebase?
Thanks,
 ...Duane
in-gitvger@baka.org· Oct 6, 2011, 20:31 UTC · re: Duane Murphy · lore

Re: Pull --rebase looses merge information

In message <DECF417E-50BB-4963-965C-BEF1B5C95DAC@mac.com>, Duane Murphy writes:
    $ git merge topic
    $ git pull 
        merge by rebase; implied by config
    $ git push
    The result of this process is that the file changes are pushed but
    the reference back to the topic branch has been lost. This makes
    it appear as though the topic branch has not been merged properly.
[...]
    Is there a bug here? Is there some way to avoid this situation
    without sacrificing the benefits of pull --rebase?
Yes, but it currently is annoying.

Instead of `git pull --rebase` you need to run `git fetch && git rebase -p @{u}`

It would be very nice if the -p argument to rebase could be automatically included in the `git pull --rebase`.

I personally believe all pull should be --rebase, all merges should be --no-ff, and all rebases should be -p. At least by default. But that is just me.

					-Seth Robertson

← back to recent threads