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

Re: re-running merge on a single file

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 12, 2010, 23:07 UTC
Message-ID
<7v3a05p29w.fsf@alter.siamese.dyndns.org>
In-Reply-To
<a038bef51003121216l5c0a4942qabc3d12741c9030e@mail.gmail.com>
Chris Packham <judge.packham@gmail.com> writes:
> ... I'm lazy and my
> projects rules allow broken commits so ...

We cannot fix, nor it is our job to fix, lazy people or undisciplined projects ;-)

Having said that you can still retry your merge, which was _mostly_ Ok.
 (1) First, check out the original commit before the merge.  You may have
     built a few more commits on top of it, so "git log --first-parent"
     may help to find that commit.  Suppose you found that merge commit
     and we call that $merge; then:
     $ git checkout $merge^1
   
 (2) Then you retry that merge:
     $ git merge $merge^2
     which would conflict the same way you saw.
 (3) If you have rerere enabled, then the conflicts would be already
     resolved in your working tree at this point, but not in the index, so
     you can reproduce the conflicted state with "checkout -m".
 (4) If you didn't have rerere enabled, then you would have a lot of
     conflicted files in the working tree.  Inspect them by comparing with
     $merge:
     $ git diff $merge
     Since we are assuming that most of the resolution was good, and you
     know what paths you want to fix your earlier resolution for, you
     would want to take what is in $merge for most of the paths.  You can
     run checkout on paths that you know were good in $merge, like so:
     $ git checkout $merge -- include/ drivers/
     and repeat this step to narrow it down to the paths you are
     interested in.
 (5) After you fix the resolution and make a commit,
     $ git diff $merge
     will show that your earlier incorrect resolution is replaced by a new
     correct resolution.
After that, you can rebase your branch on top of HEAD to conclude.

Note that recent git can use "checkout -m path" to reproduce conflicts even after you ran "git add path".

Previous: Chris PackhamNext: Chris Packham
Message 11 of 14 in “re-running merge on a single file”
  1. Chris PackhamMar 11, 2010
  2. Chris PackhamMar 11, 2010
  3. Markus HeidelbergMar 11, 2010
  4. Chris PackhamMar 11, 2010
  5. Jakub NarebskiMar 11, 2010
  6. Chris PackhamMar 12, 2010
  7. Johannes SixtMar 12, 2010
  8. Junio C HamanoMar 12, 2010
  9. Chris PackhamMar 12, 2010
  10. Chris PackhamMar 12, 2010
  11. Junio C HamanoMar 12, 2010
  12. Chris PackhamMar 12, 2010
  13. Kris ShannonMar 14, 2010
  14. Jakub NarebskiMar 12, 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.