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

Re: Commiting changes onto more than one branch

From
Thomas Rast <trast@student.ethz.ch>
Date
Nov 25, 2009, 16:47 UTC
Message-ID
<200911251747.57456.trast@student.ethz.ch>
In-Reply-To
<6b4a562b0911250831q332ac3b5m6ee38f59e7a6f391@mail.gmail.com>
Mike Jarmy wrote:
Show 9 quoted lines
> Suppose that I checkout the v3 branch, and fix the bug by editing
> several different files.  (Lets assume for now that the files in
> question have not diverged between any of the 3 branches, even though
> tons of other files have changed).  How do I commit the bugfix into
> all of v3, v4 and v5?  Clearly, merging the branches together would be
> bad.  So I think what I should do is perform 3 different commits, but
> I'm not quite sure how to juggle the git index (or stash or whatever)
> to accomplish this.  This may be a really obvious question, but I'm a
> confused git newbie.
You can build the fix on top of the merge-base of v3, v4 and v5, i.e.
  git checkout -b myfix $(git merge-base v3 $(git merge-base v4 v5))
  # work
  git commit
and then merge it to each of the version branches:
  for b in v3 v4 v5; do
    git checkout $b
    git merge myfix
  done

So much for the theory. In the model suggested in the gitworkflows(7) manpage and used in git.git, v3 is contained in v4 and similar for v5. This means that after merging (possibly several) fixes to v3, you can merge v3 into v4 and v4 into v5 (and so on, through all versions) to propagate the fixes.

-- 
Thomas Rast
trast@{inf,student}.ethz.ch
Previous: Andreas SchwabNext: Jakub Narebski
Message 9 of 12 in “Commiting changes onto more than one branch”
  1. Mike JarmyNov 25, 2009
  2. Eugene SajineNov 25, 2009
  3. Mike JarmyNov 25, 2009
  4. Avery PennarunNov 25, 2009
  5. Junio C HamanoNov 25, 2009
  6. Mike JarmyNov 25, 2009
  7. Daniel BarkalowNov 25, 2009
  8. Andreas SchwabNov 25, 2009
  9. Thomas RastNov 25, 2009
  10. Jakub NarebskiNov 25, 2009
  11. Mike JarmyNov 25, 2009
  12. Nicolas PitreNov 25, 2009

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.