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

Re: How to manage merges from one line while excluding its merges from another

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Jun 26, 2010, 00:03 UTC
Message-ID
<20100626000358.GA11473@burratino>
In-Reply-To
<4C252D1C.4010702@brooks.nu>
Hi Lane,
Lane Brooks wrote:
Show 7 quoted lines
> I have a tree like this:
> 
>      G---H---I---J---K   devel
>     /       /       /
> A---B---C---D---E---F    main
>         \
>          L---M---N---O   my
Nice diagram.
What is missing is a picture of what you want the result to be.
> The 'my' branch forked off the 'main' line and for reasons out of my
> control cannot merge the 'main' changes (D,E,F) back.
[...]
> I want to continue to merge from the devel line as additional commits
> are made that are not on the main branch, but I do not want any of
> the future merge commits.

(I) I am guessing that the 'main' line is not part of the published history, in which case you what you want might look like this:

         ... devel
      /
 A---B---C- ... main
          \
           L---M---N---O---H'---J' my

The J commit itself could not be included in the history of the 'my' branch because its ancestor D is not meant to be published.

(II) In an alternative scenario, the 'main' changes (D, E, F) are forbidden because they introduce bugs. In this case, a solution might look something like this:

       ...                  K devel
     /               /       \
A---B---C---D---E---F main    \
         \                     \
          L---M---N---O---------P---Q---R---S

where Q, R, and S are commits (created with ‘git revert’) that undo the effect of F, E, and D. From then on, you can just merge from devel as usual.

> Is there an automated way to do this or do I have to cherry pick
> everything by hand?
In git 1.7.2, you will be able to automate (I) as follows:
 git cherry-pick --no-merges ^my ^main devel

Until then, you might want to try experimenting with something like this:

 git rev-list --no-merges ^my ^main devel |
 while read rev
 do
	git cherry-pick $rev ||
	{
		echo >&2 cherry-pick failed
		break
	}
 done

Hope that helps, Jonathan

Previous: Lane BrooksNext: Lane Brooks
Message 2 of 4 in “How to manage merges from one line while excluding its merges from another”
  1. Lane BrooksJun 25, 2010
  2. Jonathan NiederJun 26, 2010
  3. Lane BrooksJun 26, 2010
  4. Jonathan NiederJun 26, 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.