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

RE: Rebase Question

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
May 12, 2021, 07:23 UTC
Message-ID
<609b827884bfd_6e0fc2083c@natae.notmuch>
In-Reply-To
<MN2PR07MB59526F40B255183931649AD19C529@MN2PR07MB5952.namprd07.prod.outlook.com>
Andrew Ottaviano wrote:
> The difficulty with this is that if I have merge conflicts that show
> up on my first commit, I have to resolve that stupid thing for every
> subsequent commit.

I don't quite understand that. If you have resolved the chunk, then that chunk is resolved, and the rest of the commits don't have to worry about that...

Unless they touch *precisely* the same lines as the first commit, in which case... Yeah, you have to resolve that stupid thing over and over.

> The solution that I thought of is instead of resolving conflicts from
> the bottom up (starting with earliest history), resolving from the top
> down (latest to earliest) and resolving the conflict in the commit it
> occurred.

Well, this is interesting because it's something I've wanted to write about for a long time, and it's what I call my "pronged approach".

I actually do *both*; I do a rebase and fix the problems from 1) the bottom-up, but after I have resolved the conflicts from 2) the top-down. In 1) (bottom-up) I resolve the conflicts in a rebase, and in 2) I resolve the conflicts in merge, but in *both* the end result sould be the exactly same [`git diff 1) 2)` is empty].

Yes, it is more work, but at the end of the day I'm 100% sure I did the rebase right, so I don't have to think about it that much; either there's a diff or there isn't.

In fact, I rarely do just one rebase, because quite often I miss things, so I do a second, or third, or fourth rebase, but at the end I make sure that the diff with the merge (top-down approach) is the same.

To facilitate this work I use two tools: 1) git rerere [1] (others have mentioned this), and 2) git reintegrate [2] (only useful if there's more than one branch you are merging).

Yeah, it's a lot of work, but I'd rather do a lot of tedious work that I'm 100% sure is correct, than do a little bit of work that I can't easily verify.

Cheers.

[1] https://git-scm.com/docs/git-rerere [2] https://github.com/felipec/git-reintegrate

-- 
Felipe Contreras
Previous: Junio C Hamano
Message 6 of 6 in “Rebase Question”
  1. Andrew OttavianoMay 12, 2021
  2. Jacob KellerMay 12, 2021
  3. Bryan TurnerMay 12, 2021
  4. Jeff KingMay 12, 2021
  5. Junio C HamanoMay 12, 2021
  6. Felipe ContrerasMay 12, 2021

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.