# Re: Amending merge commits?

10 messages from 2014-07-28 to 2014-07-30. Participants: Nico Williams, Sergei Organov, Philip Oakley.
Thread: https://gitlist.dev/t/37235

## Nico Williams, 2014-07-28 21:47

Subject: Re: Amending merge commits?
Message-ID: <CAK3OfOjr6ej5VdGU=bLmtag9cca1=ogLxVakCFTMG7b-A2uBiA@mail.gmail.com>
URL: https://gitlist.dev/e/CAK3OfOjr6ej5VdGU%3DbLmtag9cca1%3DogLxVakCFTMG7b-A2uBiA%40mail.gmail.com

```
On Mon, Jul 28, 2014 at 3:00 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:
> Sergei Organov wrote:
>
>> Is there any scenario at all where pull --rebase=true wins over
>> preserve?
>
> Basically always in my book. ;-)
>
> When people turn on 'pull --rebase', they are asking for a clean,
> simplified history where their changes are small discrete patches in a
> clump on top of upstream.

+1.  Words to develop by.

There are exceptions.  E.g., when you pull commits from multiple
[forked] upstreams, then you can't keep your local commits on top.

That exception aside, keeping all local commits "on top" by always
rebasing them onto the upstream is extremely useful: a) in simplifying
conflict resolution, b) making it easy to identify as-yet-unintegrated
local commits, c) making it easy to contribute local commits.

Nico
--

```

## Sergei Organov, 2014-07-29 09:58

Subject: Re: Amending merge commits?
Message-ID: <87r4147agk.fsf@osv.gnss.ru>
URL: https://gitlist.dev/e/87r4147agk.fsf%40osv.gnss.ru
In-Reply-To: <CAK3OfOjr6ej5VdGU=bLmtag9cca1=ogLxVakCFTMG7b-A2uBiA@mail.gmail.com>

```
Nico Williams <nico@cryptonector.com> writes:

> On Mon, Jul 28, 2014 at 3:00 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:
>> Sergei Organov wrote:
>>
>>> Is there any scenario at all where pull --rebase=true wins over
>>> preserve?
>>
>> Basically always in my book. ;-)
>>
>> When people turn on 'pull --rebase', they are asking for a clean,
>> simplified history where their changes are small discrete patches in a
>> clump on top of upstream.
>
> +1.  Words to develop by.
>
> There are exceptions.  E.g., when you pull commits from multiple
> [forked] upstreams, then you can't keep your local commits on top.
>
> That exception aside, keeping all local commits "on top" by always
> rebasing them onto the upstream is extremely useful: a) in simplifying
> conflict resolution, b) making it easy to identify as-yet-unintegrated
> local commits, c) making it easy to contribute local commits.

But 'pull --rebase=preserve' does rebase local commits onto the
upstream, and result is exactly the same as 'pull --rebase=true', unless
you have some of your own merges to be rebased. That's where the
difference between these two options appears. It's --rebase=false that
performs merges rather than rebase.

Overall, I still can't see where '--rebase=true' wins over
'--rebase=preserve'.

-- 
Sergey.

```

## Nico Williams, 2014-07-29 15:44

Subject: Re: Amending merge commits?
Message-ID: <CAK3OfOhFzbUA7gZbox84W=VC+0aSuiNc-XRP_MTyYy1UeFFzZQ@mail.gmail.com>
URL: https://gitlist.dev/e/CAK3OfOhFzbUA7gZbox84W%3DVC%2B0aSuiNc-XRP_MTyYy1UeFFzZQ%40mail.gmail.com
In-Reply-To: <87r4147agk.fsf@osv.gnss.ru>

```
On Tue, Jul 29, 2014 at 4:58 AM, Sergei Organov <osv@javad.com> wrote:
> Nico Williams <nico@cryptonector.com> writes:
>> That exception aside, keeping all local commits "on top" by always
>> rebasing them onto the upstream is extremely useful: a) in simplifying
>> conflict resolution, b) making it easy to identify as-yet-unintegrated
>> local commits, c) making it easy to contribute local commits.
>
> But 'pull --rebase=preserve' does rebase local commits onto the
> upstream, and result is exactly the same as 'pull --rebase=true', unless
> you have some of your own merges to be rebased. That's where the
> difference between these two options appears. It's --rebase=false that
> performs merges rather than rebase.

Local merge commits mean that you either didn't rebase to keep all
your local commits on top of the upstream, or that you have multiple
upstreams (the example exception I gave).

Conversely, if you always rebase your local commits on top of the
upstream then you won't have merge commits to worry about.

Nico
--

```

## Philip Oakley, 2014-07-29 19:29

Subject: Re: Amending merge commits?
Message-ID: <DFE66A48CBC646E795B3B4A0903AB19E@PhilipOakley>
URL: https://gitlist.dev/e/DFE66A48CBC646E795B3B4A0903AB19E%40PhilipOakley
In-Reply-To: <CAK3OfOhFzbUA7gZbox84W=VC+0aSuiNc-XRP_MTyYy1UeFFzZQ@mail.gmail.com>

```
From: "Nico Williams" <nico@cryptonector.com>
> On Tue, Jul 29, 2014 at 4:58 AM, Sergei Organov <osv@javad.com> wrote:
>> Nico Williams <nico@cryptonector.com> writes:
>>> That exception aside, keeping all local commits "on top" by always
>>> rebasing them onto the upstream is extremely useful: a) in 
>>> simplifying
>>> conflict resolution, b) making it easy to identify 
>>> as-yet-unintegrated
>>> local commits, c) making it easy to contribute local commits.
>>
>> But 'pull --rebase=preserve' does rebase local commits onto the
>> upstream, and result is exactly the same as 'pull --rebase=true', 
>> unless
>> you have some of your own merges to be rebased. That's where the
>> difference between these two options appears. It's --rebase=false 
>> that
>> performs merges rather than rebase.
>
> Local merge commits mean that you either didn't rebase to keep all
> your local commits on top of the upstream, or that you have multiple
> upstreams (the example exception I gave).
>
> Conversely, if you always rebase your local commits on top of the
> upstream then you won't have merge commits to worry about.
>
Whilst it may not be "the Git Way", I'd expect that in many less well 
informed companies, the need to keep merge commits fom other lines of 
development would be quite a common (political ) technique where some 
preparatory branch needs to be merged in before one's feature can be 
completed (similar to all those cases on the list when folk say 'builds 
on top of xy's commit deadbeaf)

Philip 

```

## Nico Williams, 2014-07-29 20:19

Subject: Re: Amending merge commits?
Message-ID: <CAK3OfOgZt55+tKv5455Jk-F=buULtftmCasbxHYcxGzppbWcfg@mail.gmail.com>
URL: https://gitlist.dev/e/CAK3OfOgZt55%2BtKv5455Jk-F%3DbuULtftmCasbxHYcxGzppbWcfg%40mail.gmail.com
In-Reply-To: <DFE66A48CBC646E795B3B4A0903AB19E@PhilipOakley>

```
On Tue, Jul 29, 2014 at 2:29 PM, Philip Oakley <philipoakley@iee.org> wrote:
> From: "Nico Williams" <nico@cryptonector.com>
>> Local merge commits mean that you either didn't rebase to keep all
>> your local commits on top of the upstream, or that you have multiple
>> upstreams (the example exception I gave).
>>
>> Conversely, if you always rebase your local commits on top of the
>> upstream then you won't have merge commits to worry about.
>>
> Whilst it may not be "the Git Way", I'd expect that in many less well
> informed companies, the need to keep merge commits fom other lines of
> development would be quite a common (political ) technique where some
> preparatory branch needs to be merged in before one's feature can be
> completed (similar to all those cases on the list when folk say 'builds on
> top of xy's commit deadbeaf)

The way we did this at Sun, first with Teamware, then later with
Mercurial, was as follows:

 - "projects" kept their own clone repos of the upstream
 - engineers working on a project cloned the project repo ("project gate")
 - engineers pushed/pulled to/from the project gate
 - each project gate had a gatekeeper whose job it was to periodically
rebase onto the latest upstream
 - then engineers would rebase onto the new project gate

No "merge turds" (Sun speak) were ever allowed in any upstream,
whether a project gate or the ultimate upstream.  All commits had to
be organized according to specific rules, and squashed.  These rules
applied at the project gate and in the upstream.

 - when the project was ready for integration the gatekeeper would
rebase and squash as necessary, then push to the upstream

(I'm eliding some details.  In particular when an intermediate
upstream rebased the previous head was left available as a "snapshot"
to make the equivalent of git rebase --onto possible.)

The upshot was: all local commits were always on top of whatever the
next upstream in the chain was.  Always.  No merge commits ever.

That workflow works just fine with git.  It worked really well at Sun
(with thousands of engineers working on Solaris alone).  And it should
work well for anyone who doesn't have two or more forked upstreams to
follow.

Nico
--

```

## Philip Oakley, 2014-07-29 21:38

Subject: Re: Amending merge commits?
Message-ID: <9EFB89B516004883AC0FD774595B84E7@PhilipOakley>
URL: https://gitlist.dev/e/9EFB89B516004883AC0FD774595B84E7%40PhilipOakley
In-Reply-To: <CAK3OfOgZt55+tKv5455Jk-F=buULtftmCasbxHYcxGzppbWcfg@mail.gmail.com>

```
From: "Nico Williams" <nico@cryptonector.com>
> On Tue, Jul 29, 2014 at 2:29 PM, Philip Oakley <philipoakley@iee.org> 
> wrote:
>> From: "Nico Williams" <nico@cryptonector.com>
>>> Local merge commits mean that you either didn't rebase to keep all
>>> your local commits on top of the upstream, or that you have multiple
>>> upstreams (the example exception I gave).
>>>
>>> Conversely, if you always rebase your local commits on top of the
>>> upstream then you won't have merge commits to worry about.
>>>
>> Whilst it may not be "the Git Way", I'd expect that in many less well
>> informed companies, the need to keep merge commits fom other lines of
>> development would be quite a common (political ) technique where some
>> preparatory branch needs to be merged in before one's feature can be
>> completed (similar to all those cases on the list when folk say 
>> 'builds on
>> top of xy's commit deadbeaf)
>
> The way we did this at Sun, first with Teamware, then later with
> Mercurial, was as follows:
>
> - "projects" kept their own clone repos of the upstream
> - engineers working on a project cloned the project repo ("project 
> gate")
> - engineers pushed/pulled to/from the project gate
> - each project gate had a gatekeeper whose job it was to periodically
> rebase onto the latest upstream
> - then engineers would rebase onto the new project gate
>
> No "merge turds" (Sun speak) were ever allowed in any upstream,
> whether a project gate or the ultimate upstream.  All commits had to
> be organized according to specific rules, and squashed.  These rules
> applied at the project gate and in the upstream.
>
> - when the project was ready for integration the gatekeeper would
> rebase and squash as necessary, then push to the upstream
>
> (I'm eliding some details.  In particular when an intermediate
> upstream rebased the previous head was left available as a "snapshot"
> to make the equivalent of git rebase --onto possible.)
>
> The upshot was: all local commits were always on top of whatever the
> next upstream in the chain was.  Always.  No merge commits ever.
>
> That workflow works just fine with git.

I'm not saying that it isn't a good technique and can work well. Rather 
I'm saying we should be tolerant of the rules and techniques of others 
who do have 'merges' in their workflow organisation. They may have a 
very long QA delay between feature 'done' and feature 'done done tested 
merged', which requires maintaining merges of done items that aren't yet 
merged to master. Such techniques are more common in mixed engineering 
than pure software environments (where engineering rules apply, and 
software has to follow)

>  It worked really well at Sun
> (with thousands of engineers working on Solaris alone).  And it should
> work well for anyone who doesn't have two or more forked upstreams to
> follow.

I'm just cautious of an accidental one size fits all approach, so the 
ability to rebase lines of development which contain merge commits 
should be possible (with an appropriate and documented option) without 
hidden traps.
>
Philip 

```

## Nico Williams, 2014-07-29 22:07

Subject: Re: Amending merge commits?
Message-ID: <CAK3OfOgsY43oiuUNggS+Tz2zfMKB_eO2U+S2tiNsoYGk5qhn2w@mail.gmail.com>
URL: https://gitlist.dev/e/CAK3OfOgsY43oiuUNggS%2BTz2zfMKB_eO2U%2BS2tiNsoYGk5qhn2w%40mail.gmail.com
In-Reply-To: <9EFB89B516004883AC0FD774595B84E7@PhilipOakley>

```
On Tue, Jul 29, 2014 at 4:38 PM, Philip Oakley <philipoakley@iee.org> wrote:
> From: "Nico Williams" <nico@cryptonector.com>
>> That workflow works just fine with git.
>
> I'm not saying that it isn't a good technique and can work well. Rather I'm
> saying we should be tolerant of the rules and techniques of others who do
> [...]

Sure.  I was just giving advice as to how to avoid any problems at
pull time w.r.t. local merge commits.

Better merge commit handling at pull time might be great (I'd not
know; I avoid local merge commits!), but I would still strongly
recommend keeping all local commits on top because otherwise you lose
local history.  Even if you use -m to set a better commit message, you
might prefer to have kept the original N local -now rebased- commits
around so you can tell what each discrete change was, even if you'll
eventually squash them (you might not squash them all into one).

>>  It worked really well at Sun
>> (with thousands of engineers working on Solaris alone).  And it should
>> work well for anyone who doesn't have two or more forked upstreams to
>> follow.
>
> I'm just cautious of an accidental one size fits all approach, so the
> ability to rebase lines of development which contain merge commits should be
> possible (with an appropriate and documented option) without hidden traps.

Thus far the only case I've seen where this approach doesn't work _at
all_ is the case where you have multiple forked upstreams.  The only
other case where it doesn't work is a social problem: rebase allergy.
For the repos I maintain I insist on contributed commits applying as
fast forward merges, or I'll rebase them myself if need be.

Nico
--

```

## Sergei Organov, 2014-07-30 08:42

Subject: Re: Amending merge commits?
Message-ID: <87siljxmnh.fsf@osv.gnss.ru>
URL: https://gitlist.dev/e/87siljxmnh.fsf%40osv.gnss.ru
In-Reply-To: <CAK3OfOhFzbUA7gZbox84W=VC+0aSuiNc-XRP_MTyYy1UeFFzZQ@mail.gmail.com>

```
Nico Williams <nico@cryptonector.com> writes:

> On Tue, Jul 29, 2014 at 4:58 AM, Sergei Organov <osv@javad.com> wrote:
>> Nico Williams <nico@cryptonector.com> writes:
>>> That exception aside, keeping all local commits "on top" by always
>>> rebasing them onto the upstream is extremely useful: a) in simplifying
>>> conflict resolution, b) making it easy to identify as-yet-unintegrated
>>> local commits, c) making it easy to contribute local commits.
>>
>> But 'pull --rebase=preserve' does rebase local commits onto the
>> upstream, and result is exactly the same as 'pull --rebase=true', unless
>> you have some of your own merges to be rebased. That's where the
>> difference between these two options appears. It's --rebase=false that
>> performs merges rather than rebase.
>
> Local merge commits mean that you either didn't rebase to keep all
> your local commits on top of the upstream, or that you have multiple
> upstreams (the example exception I gave).

I rather have multiple (release) branches on single upstream, say, v2.3
and v2.4. When something needs to be fixed in 2.3, it's fixed there and
pushed upstream, then, on 2.4, the 2.3 is merged to it, and result is
pushed upstream. When I do this merge, I need to push the merge
upstream, and this won't work reliably when --rebase=true is acitve
(through pull.merge=rebase). If nothing changes upstream, I can simply
push this, and the merge is correctly preserved. However, if somebody
makes any changes upstream while I perform the merge, I'll need to pull
before pushing, and this immediately flattens-out my merge, that is
absolutely not what is needed here. Or I can simply pull before push,
just in case, and this flattens history even when there are no any
changes upstream!

Once again, nobody yet gave any clue of when/why pull.merge=preserve
configuration is inferior to pull.merge=rebase, as for all the scenario
you seem to care about they bring the same result.

> Conversely, if you always rebase your local commits on top of the
> upstream then you won't have merge commits to worry about.

Wrong. I do alwys rebase my local commits on top of upstream, but I
still do have my own merge commits to worry about, as explained above.

-- 
Sergey.

```

## Nico Williams, 2014-07-30 17:43

Subject: Re: Amending merge commits?
Message-ID: <CAK3OfOgcO9dmePtXCu9gUSf2bdQytJf9-RCZDXhv9Gy8UVyDOQ@mail.gmail.com>
URL: https://gitlist.dev/e/CAK3OfOgcO9dmePtXCu9gUSf2bdQytJf9-RCZDXhv9Gy8UVyDOQ%40mail.gmail.com
In-Reply-To: <87siljxmnh.fsf@osv.gnss.ru>

```
On Wed, Jul 30, 2014 at 3:42 AM, Sergei Organov <osv@javad.com> wrote:
> Nico Williams <nico@cryptonector.com> writes:
>> Local merge commits mean that you either didn't rebase to keep all
>> your local commits on top of the upstream, or that you have multiple
>> upstreams (the example exception I gave).
>
> I rather have multiple (release) branches on single upstream, say, v2.3
> and v2.4. When something needs to be fixed in 2.3, it's fixed there and
> pushed upstream, then, on 2.4, the 2.3 is merged to it, and result is
> pushed upstream. When I do this merge, I need to push the merge

Hmm, why not cherry-pick the fix?  That's how every project I know
that ports fixes across release branches does it.

> upstream, and this won't work reliably when --rebase=true is acitve
> (through pull.merge=rebase). If nothing changes upstream, I can simply
> push this, and the merge is correctly preserved. However, if somebody
> makes any changes upstream while I perform the merge, I'll need to pull
> before pushing, and this immediately flattens-out my merge, that is
> absolutely not what is needed here. Or I can simply pull before push,
> just in case, and this flattens history even when there are no any
> changes upstream!

Does this change if you give your merge commits an different commit message?

>> Conversely, if you always rebase your local commits on top of the
>> upstream then you won't have merge commits to worry about.
>
> Wrong. I do alwys rebase my local commits on top of upstream, but I
> still do have my own merge commits to worry about, as explained above.

If you cherry-pick the cross-release-branch commits you'll not have a
merge commit to worry about.

Nico
--

```

## Sergei Organov, 2014-07-30 18:28

Subject: Re: Amending merge commits?
Message-ID: <877g2uu2ew.fsf@osv.gnss.ru>
URL: https://gitlist.dev/e/877g2uu2ew.fsf%40osv.gnss.ru
In-Reply-To: <CAK3OfOgcO9dmePtXCu9gUSf2bdQytJf9-RCZDXhv9Gy8UVyDOQ@mail.gmail.com>

```
Nico Williams <nico@cryptonector.com> writes:

> On Wed, Jul 30, 2014 at 3:42 AM, Sergei Organov <osv@javad.com> wrote:
>> Nico Williams <nico@cryptonector.com> writes:
>>> Local merge commits mean that you either didn't rebase to keep all
>>> your local commits on top of the upstream, or that you have multiple
>>> upstreams (the example exception I gave).
>>
>> I rather have multiple (release) branches on single upstream, say, v2.3
>> and v2.4. When something needs to be fixed in 2.3, it's fixed there and
>> pushed upstream, then, on 2.4, the 2.3 is merged to it, and result is
>> pushed upstream. When I do this merge, I need to push the merge
>
> Hmm, why not cherry-pick the fix?  That's how every project I know
> that ports fixes across release branches does it.

Cherry-pick? Why bother? What problem do we solve, having no merges
whatsoever? Why? GIT is so good at merges!

My impression is that people mostly rather do topic branches, and merge
them wherever they need the fixes, no?

>> upstream, and this won't work reliably when --rebase=true is acitve
>> (through pull.merge=rebase). If nothing changes upstream, I can simply
>> push this, and the merge is correctly preserved. However, if somebody
>> makes any changes upstream while I perform the merge, I'll need to pull
>> before pushing, and this immediately flattens-out my merge, that is
>> absolutely not what is needed here. Or I can simply pull before push,
>> just in case, and this flattens history even when there are no any
>> changes upstream!
>
> Does this change if you give your merge commits an different commit
> message?

Different from what? I'm almost sure commit message has nothing to do
with it. Please refer to this explanation to see for yourself how git
behaves when rebasing:

http://www.mail-archive.com/git%40vger.kernel.org/msg55605.html

>
>>> Conversely, if you always rebase your local commits on top of the
>>> upstream then you won't have merge commits to worry about.
>>
>> Wrong. I do alwys rebase my local commits on top of upstream, but I
>> still do have my own merge commits to worry about, as explained above.
>
> If you cherry-pick the cross-release-branch commits you'll not have a
> merge commit to worry about.

I fail to see why do you consider merge commits to be an evil, really. I
didn't think about cherry-picking carefully, but I don't feel
cherry-picking is the best tool for the job here. I suspect random
cherry-picking would create a mess, sooner or later.

-- 
Sergey.

```
