threads / discuss / 22984

Doing a dummy or empty merge

Subject: Doing a dummy or empty merge

## tl;dr

5 messages between Mar 11, 2010 and Mar 15, 2010.

replies: 4people: 3as markdown or json

Richard Lee· Mar 11, 2010, 12:16 UTC · lore
Hi again git-list,

This is a question regarding merging following directly on from my last question about workflows.

I was recommended a workflow by Jon Seymour to handle multiple deployments of the same project. In a nutshell, the workflow was to keep a main branch that reflects a generic undeployed state and keep each deployment along with the deployment artifacts in a seperate branch.

I don't have a generic branch as such. It's not have the way software I was given to work on works. I do have a live/production branch.

I have just created a local/test branch. So far I have made and committed and changes that enables the project to run on my local machine.

At this point I want to merge this test branch into the live branch despite not having made any commits apart from deployment related changes on the test branch. I want this to be a dummy merge so that a merge is recorded into the live branch, but the contents of the live branch remain untouched. This is as if I made an empty commit on the live branch.

The reason why I want to do this is that I want a point on the test branch that represents when all deployment-specific commits have been made. Any further commits from this point onwards are additional features or bug fixes that are unrelated to the deployment. So any further merges from this point onwards into the live branch will only bring over these additional features and fixes. The deployment settings on the live branch will remain untouched as I have made a 'dummy' merge already.

I think a nice additional consequence would be that any resulting merge conflicts would probably indicate that I have made deployment specific commits rather than any features of bug fixes.

So the question is how do a do a dummy or empty merge as described? So far I can only thing of doing a --no-commit merge, then checking out all changed files from the live branch. Is there a neater way of doing this? I assume this would be like the merge using the 'theirs' strategy, but the strategy would be used on all merge changes rather than just conflicts.

Or is there a better way of implementing this workflow?
Regards,
Richard
Randal L. Schwartz· Mar 11, 2010, 17:21 UTC · re: Richard Lee · lore

Re: Doing a dummy or empty merge

>>>>> "Richard" == Richard Lee <richard@webdezign.co.uk> writes:

Richard> At this point I want to merge this test branch into the live branch Richard> despite not having made any commits apart from deployment related Richard> changes on the test branch. I want this to be a dummy merge so that a Richard> merge is recorded into the live branch, but the contents of the live Richard> branch remain untouched. This is as if I made an empty commit on the Richard> live branch.

I think you'll get what you want with a "merge -s ours" from test to live. That says that "I've looked at test, and I've looked at the parents of live, and this is how I want the result to look".

Further commits on test can then be merged to live automatically using this new merge as the (initial) base. Of course, later commits after that will use subsequent bases, but that should already work the way you want.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
Junio C Hamano· Mar 11, 2010, 20:26 UTC · re: Randal L. Schwartz · lore

Re: Doing a dummy or empty merge

merlyn@stonehenge.com (Randal L. Schwartz) writes:
Show 17 quoted lines
>>>>>> "Richard" == Richard Lee <richard@webdezign.co.uk> writes:
>
> Richard> At this point I want to merge this test branch into the live branch
> Richard> despite not having made any commits apart from deployment related
> Richard> changes on the test branch. I want this to be a dummy merge so that a
> Richard> merge is recorded into the live branch, but the contents of the live
> Richard> branch remain untouched. This is as if I made an empty commit on the
> Richard> live branch.
>
> I think you'll get what you want with a "merge -s ours" from test
> to live.  That says that "I've looked at test, and I've looked at
> the parents of live, and this is how I want the result to look".
>
> Further commits on test can then be merged to live automatically using
> this new merge as the (initial) base.  Of course, later commits after
> that will use subsequent bases, but that should already work the way you
> want.

After the above "merge -s ours", you obviously can never merge from live to test. You have declared that you favor the live configuration over the test configuration with that merge commit, and merging a branch that has that merge commit (i.e. live) into any branch (i.e. test) is your consent to be bound by that declaration. The resulting backmerge will wipe the test configuration and replace it with that from live.

Not that anybody would be likely to want to merge live back to test, but I thought it is worth a warning, as people who haven't thought through what it means to make a merge commit (or more generally, any commit) can get confused.

Randal L. Schwartz· Mar 11, 2010, 21:16 UTC · re: Junio C Hamano · lore

Re: Doing a dummy or empty merge

>>>>> "Junio" == Junio C Hamano <gitster@pobox.com> writes:

Junio> After the above "merge -s ours", you obviously can never merge from Junio> live to test. You have declared that you favor the live configuration Junio> over the test configuration with that merge commit, and merging a Junio> branch that has that merge commit (i.e. live) into any branch Junio> (i.e. test) is your consent to be bound by that declaration. The Junio> resulting backmerge will wipe the test configuration and replace it Junio> with that from live.

Very good point.  But a cherry-pick would work, right?
-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
Richard Lee· Mar 15, 2010, 18:21 UTC · re: Randal L. Schwartz · lore

RE: Doing a dummy or empty merge

>>>>> "Junio" == Junio C Hamano <gitster@pobox.com> writes:
Show 7 quoted lines
>> After the above "merge -s ours", you obviously can never merge from
>> live to test.  You have declared that you favor the live
>> configuration over the test configuration with that merge commit, and
>> merging a branch that has that merge commit (i.e. live) into any
>> branch (i.e. test) is your consent to be bound by that declaration.
>> The resulting backmerge will wipe the test configuration and replace
>> it with that from live.

Yes I have now come across this issue. I was working on the live branch directly as it was a small change and was easier to work with the live platform. Now I don't have a way to merge the changes from the live branch into the test branch without overwriting the test configuration.

>Very good point.  But a cherry-pick would work, right?

Yes a cherry-pick would work. But is there a "neater" way to do this, possibly using merging? I prefer merging over cherry-picking because merging will use the common ancestor so that only the succeeding commits are taken into account. After a while, keeping track of what has and has not been cherry-picked would be difficult.

I get the feeling there is a better way to set out my branches/workflow. Is there a way I can have a branch for each deployment where I can merge over any changes in either direction between any two branches? Would I need some sort of central "vanilla" branch for this?

← back to recent threads