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

Re: "git merge" merges too much!

From
Dmitry Potapov <dpotapov@gmail.com>
Date
Nov 30, 2009, 19:22 UTC
Message-ID
<20091130192212.GA23181@dpotapov.dyndns.org>
In-Reply-To
<m1NFAji-000kn2C@most.weird.com>
On Mon, Nov 30, 2009 at 01:12:31PM -0500, Greg A. Woods wrote:
> 
> The way "git merge" works does concern me somewhat though as I try to
> figure out how I might use "topic" branches to develop local features
> and then merge them onto each supported release branch.

The basic idea of using topic branches is development is done on separate branches are merged to the release branch only when they are ready to be released. These branches are based on the oldest branch in what they may be included. It means that fixes are normally based on the stable branch and new feature are based on the master branch, i.e. the branch that contains changes for the next new feature release. Not all branches got merged immediately into master. For instance, the git project has 'pu' (proposed updates) and 'next' branches. Only when a new feature proved itself to be useful and reliable, it is "graduated" to the master branch. Thus the master branch is rather stable and it is released on regular intervals (no need for a long stabilization period).

The key difference comparing to what you may got used is that branches are normally based on the oldest branch in what this feature may be included. Thus normally changes are not backported to old branches, because you can merge them directly.

Show 6 quoted lines
> > Yes, you must cherry-pick or use rebase (which is a more featureful
> > version of the pipeline you mentioned).
> 
> "git rebase" will not work for me unless it grows a "copy" option ,
> i.e. one which does not delete the original branch (i.e. avoids the
> "reset" phase of its operation).

There is no reset phase... It is just reassigning the head of branch to point to a different commit-id. If you want to copy a branch instead of rebasing the old one, you create a new branch (a new name) that points to the same commit as the branch that you want to copy, after that you rebase this new branch. You can do that like this:

$ git branch new-foo foo
$ git rebase --onto newbase oldbase new-foo
Show 5 quoted lines
> It likely wouldn't make sense to base this new "copy" feature directly
> on "git rebase" though, especially in light of all the warnings about
> how "git rebase" isn't friendly when applied to already published
> branches.  I think in theory this "copy" feature won't cause problems
> for already-published branches.

The "copy" does not have the problem of rebase, but it has a different problem: You have two series of commits instead of one. If you found a bug in one of those commits, you will have to patch each series separately. Also, git merge may produce additional conflicts... So, copying commits is not something that I would recommend to do often.

Dmitry
Previous: Greg A. WoodsNext: Greg A. Woods
Message 4 of 33 in “"git merge" merges too much!”
  1. Greg A. WoodsNov 29, 2009
  2. Jeff KingNov 29, 2009
  3. Greg A. WoodsNov 30, 2009
  4. Dmitry PotapovNov 30, 2009
  5. Greg A. WoodsDec 1, 2009
  6. Dmitry PotapovDec 1, 2009
  7. Greg A. WoodsDec 1, 2009
  8. Dmitry PotapovDec 2, 2009
  9. Nanako ShiraishiDec 2, 2009
  10. Jeff KingDec 2, 2009
  11. Greg A. WoodsDec 3, 2009
  12. Junio C HamanoDec 3, 2009
  13. Greg A. WoodsDec 3, 2009
  14. Jeff KingDec 3, 2009
  15. Uri OkrentDec 3, 2009
  16. Marko KreenDec 3, 2009
  17. Greg A. WoodsDec 9, 2009
  18. Jeff KingDec 3, 2009
  19. Junio C HamanoNov 29, 2009
  20. Greg A. WoodsNov 30, 2009
  21. Junio C HamanoNov 30, 2009
  22. Dmitry PotapovNov 30, 2009
  23. Greg A. WoodsDec 1, 2009
  24. Dmitry PotapovDec 1, 2009
  25. Greg A. WoodsDec 1, 2009
  26. Dmitry PotapovDec 1, 2009
  27. Greg A. WoodsDec 1, 2009
  28. Dmitry PotapovDec 1, 2009
  29. Jeff EplerDec 1, 2009
  30. Greg A. WoodsDec 1, 2009
  31. Dmitry PotapovDec 2, 2009
  32. Greg A. WoodsDec 3, 2009
  33. Junio C HamanoDec 2, 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.