1

I am using git. I want to merge files from branch test to my master. I did git merge --no-ff test. Now git status shows

# On branch master
# Changes to be committed:
#
#   new file:   a.txt
#   modified:   b.txt
#   renamed:    c.txt
#   deleted:    d.txt
#
# Unmerged paths:
#   (use "git add/rm <file>..." as appropriate to mark resolution)
#
#   both added:         e.txt
#   both modified:      f.txt
#   both modified:      g.txt
#   deleted by us:      h.txt
#   deleted by them:    i.txt

Now I proceeded by git mergetool. I am using meld as my merge tool. Everything is fine till now. I resolved conflicts only on e.txt, f.txt and g.txt. Files h.txt and i.txt are not resolved yet. So haven't commited anything yet. Now I thought I have done some mistakes. I want to revisit what I have done so far. I want to have a re-look at e.txt, f.txt and g.txt.

How can I do it?

I tried to rerun git mergetool. But it doesn't show e.txt, f.txt and g.txt. It starts with h.txt and i.txt. :-(

For simplifying the situation I have given this txt files as an example. But actually I am trying to merge more than 500 files and more than 100 is with conflicts!

Please suggest.

  • If you don't have `mergetool.keepBackup` set to false, then you'd have backups (*.orig files) created by `git` upon merging. – devnull Jul 13 '13 at 09:25
  • The problem I see is, `git mergetool` automatically stages files for commit after I save file and quit meld. Those files are no more found in `Unmerged paths:` section of `git status`. I found `git checkout -m ` helps getting a file back to `Unmerged paths:` section of `git status`, when it is marked as `both modified:`. So that I can re run `git mergetool` on it. Similarly, how to revert back conflict resolution of files marked as `both added:`, `deleted by us:`, `deleted by them:` etc.? –  Jul 13 '13 at 10:51

1 Answers1

0

Restarting the conflict resolution is indeed:

git checkout -m FILE

Similarly, how to revert back conflict resolution of files marked as both added:, deleted by us:, deleted by them

As mentioned here:

You can get contents of file with conflict markers using git checkout --conflict=merge -- file, but if you have cleaned up index by using git add file (or if GUI did that for you) it wouldn't work.

There is git update-index --unresolve, but it is hacky, and does not work very reliably.
I think the state it restores would be not enough for git-mergetool.

(That was in 2010: it could work better in 2018)

You would probably have to redo merge, or use git update-index --cacheinfo to manually set stages version.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250