git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Ignoring commits when merging

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Aug 18, 2010, 23:38 UTC
Message-ID
<20100818233809.GF2346@burratino>
In-Reply-To
<AANLkTi=MLE6WEmmDb6964-wX4f79ucpGU6SPieQK66ry@mail.gmail.com>
Mike Strauch wrote:
Show 6 quoted lines
> We have a
> maintenance branch in which the majority of commits are bug fixes.  We
> would then like to merge those bug fixes into our master branch.  The
> difference being that there will occasionally be a commit in our
> maintenance branch that we do not want to merge into our master branch
> because it contains application version information

I see. Yes, this is interesting (and not covered by gitworkflows though it should be).

Show 10 quoted lines
> 1. We fix some bugs in the maint branch (previous bug fixes)
> 2. We test those fixes
> 3. Merge the fixes back into master (M1)
> 4. Commit version information to maint branch (version info commit)
> 5. Release from maint branch (v1.0)
> 6. Start the process over from step 1 but with the version information
> commit in the maint branch commit history.
> 
> So, in this scenario there is really only ever 1 commit that we don't
> want to be merged into master from the maint branch.

Now your "merge -s ours" solution is looking like a good one. So the workflow on the release day might look like this:

 1. Fix some bugs on maint
 2. Test them
 3. Merge fixes back into master
 4. Version info commit on the maint branch
 5. Test a little more, tag the release.
 6. "merge -s ours" from maint to master
 7. Do some other work on topic branches and master.
 8. Push.

Ideally, in the published history, maint would _always_ be an ancestor of master. Life is simpler that way.

> This is not
> always the case of course.  There could be some other commits in maint
> branch that we don't want to merge back into master.

Sure. Another possibility is to explicitly revert patches from maint, either as a separate commit or as part of a merge. The latter would generally not make sense unless it is a very small patch.

For example:
 1. Fix some bugs on maint.
 2. Notice a test on maint is passing now.  Mark it as such.
 3. ... more work on maint ...
 4. Switch to master.  Merge from maint.  Since the test is
    failing:
    i.   "git reset --keep HEAD^" (undo the merge)
    ii.  "git merge --no-commit maint"
    iii. Mark the test as expected to fail.
    iv.  "git commit", mentioning the test failure in the log message.

This is called an "evil merge" because it introduces changes that are not from either side. Used judiciously it can be useful for ensuring that every commit passes some basic tests (which might be wanted if you use "git bisect" heavily).

"git revert" is simpler, of course.

Hope that helps. Jonathan

Previous: Mike Strauch
Message 4 of 4 in “Ignoring commits when merging”
  1. Mike StrauchAug 17, 2010
  2. Jonathan NiederAug 18, 2010
  3. Mike StrauchAug 18, 2010
  4. Jonathan NiederAug 18, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.