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

Redoing a merge for a particular file

From
Chris Packham <judge.packham@gmail.com>
Date
Jul 7, 2011, 22:24 UTC
Message-ID
<CAFOYHZCFetkokgtn4z0O3nPTEy6GCTEcN0Pzc8ce-joqMzZM1Q@mail.gmail.com>
Hi All,

I'm in the middle of merging to branches and I've screwed up my manual merge, I've also got rerere enabled and I can't seem to get back into a state to trigger git mergetool again.

  $ git merge topic
  ...
  $ git mergetool
  $ make
  error: foo.c ... oops screwed up that merge.
The merge wasn't too painful so I don't mind starting again.
  $ git reset --hard HEAD^
  HEAD is now at 59c6097 ...
  $ git merge topic
  Auto-merging foo.c
  CONFLICT (content): Merge conflict in foo.c
  Auto-merging bar.c
  CONFLICT (content): bar.c
  Auto-merging otherfile1.c
  Auto-merging otherfile2.c
  Auto-merging otherfile3.c
  Resolved 'foo.c' using previous resolution.
  Resolved 'bar.c' using previous resolution.
  Automatic merge failed; fix conflicts and then commit the result.
  $ git mergetool
  No files need merging

So rerere has remembered the bad resolution of foo.c. But even if I run 'git rerere clear' and repeat the above sequence I get the same result. I seem to remember something like this coming up before. Wasn't there an option added to checkout to allow us to recreate the pre-merge state?

  $ git checkout --merge foo.c
  $ git mergetool
  No files need merging

I can manually fix the error and amend the merge commit I just thought git should be able to give me some help. I could have sworn that checkout --merge is the right thing to do. Sure enough the man page says it is "When checking out paths from the index, this option lets you recreate the conflicted merge in the specified paths." maybe this is a bug?

Looking at git status I think checkout is working as advertised but maybe the bug is with mergetool.

  $ git status
  # On branch master
  # Your branch is behind 'origin/master' by 1 commit, and can be
fast-forwarded.
  #
  # Changes to be committed:
  ....
  # Unmerged paths:
  #   (use "git add/rm <file>..." as appropriate to mark resolution)
  #
  #	both modified:      foo.c
  #

foo.c now does have conflict markers in it so I think it's crying out to be re-merged I just can't convince mergetool to do it. Am I doing something wrong?

Thanks, Chris

P.S.
  $ git --version
  git version 1.7.5.4
Next: Jeff King
Message 1 of 5 in “Redoing a merge for a particular file”
  1. Chris PackhamJul 7, 2011
  2. Jeff KingJul 7, 2011
  3. Chris PackhamJul 7, 2011
  4. Junio C HamanoJul 8, 2011
  5. Junio C HamanoJul 8, 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.