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

Re: Converting merge to rebase in the presence of conflicts

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Apr 11, 2011, 14:39 UTC
Message-ID
<4DA312AF.80100@drmicha.warpmail.net>
In-Reply-To
<BANLkTi=krC6JMEWj=a5CY1vRCcmh9b+BaQ@mail.gmail.com>
Hrvoje Nikšić venit, vidit, dixit 11.04.2011 16:13:
Show 60 quoted lines
> Is it possible to convert a merge with (resolved) conflicts into a rebase?
> 
> I find it useful to always pull commits with "git pull" because it is
> less intrusive on my local commits (if any) than "git pull --rebase",
> and it provides a nicer change summary. Also, conflict resolution
> seems more intuitive when merging than when rebasing. And If I decide
> later to rebase after all, I can simply issue "git rebase origin/bla".
> As long as there are no conflicts.
> 
> If the merge resolves conflicts, the subsequent rebase is unaware of
> that, and the conflicts must be resolved once more. Here is an example
> in a single repository that just uses 'merge' to show the scenario:
> 
> # create a common file with two lines and branch off
> printf 'foo\nbar\n' > a
> git add a && git commit -m '' a
> git add a && git commit -m 'Added.' a
> git branch somebranch
> 
> # now work on the file in both branches
> echo baz >> a
> git commit -m changed a
> git checkout somebranch
> echo qux >> a
> git commit -m changed2 a
> 
> # we're on somebranch and decide to merge our changes with master:
> git merge master
> vi a           # resolve conflicts
> git add a
> git commit     # commit the merge
> 
> At this point say the developer on somebranch changes his mind and
> wants to rebase after all. The result is, again, a conflict:
> 
> # try to change merge to rebase
> git rebase master
> [... long output on conflicts ...]
> 
> First, rewinding head to replay your work on top of it...
> Applying: changed2
> Using index info to reconstruct a base tree...
> Falling back to patching base and 3-way merge...
> Auto-merging a
> CONFLICT (content): Merge conflict in a
> Failed to merge in the changes.
> Patch failed at 0001 changed2
> 
> When you have resolved this problem run "git rebase --continue".
> If you would prefer to skip this patch, instead run "git rebase --skip".
> To restore the original branch and stop rebasing run "git rebase --abort".
> 
> 
> Is there a way to rebase the branch without redoing conflict
> resolution? Some option to rebase, or a trick with rebase -i? The
> conflict resolution must obviously go into some commit, it would be
> nice to be able to choose whether to amend an existing commit with the
> additional changes or to add a new commit.
> 
> Hrvoje

If you enable rerere before the merge then the merge resolution is recorded and can be reused by rebase. It still stops but applied the previous resolution automatically already.

Michael
Previous: Hrvoje NikšićNext: Johannes Sixt
Message 2 of 6 in “Converting merge to rebase in the presence of conflicts”
  1. Hrvoje NikšićApr 11, 2011
  2. Michael J GruberApr 11, 2011
  3. Johannes SixtApr 11, 2011
  4. Hrvoje NikšićApr 11, 2011
  5. Michael HaggertyApr 12, 2011
  6. Johannes SixtApr 12, 2011

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.