2

So I have master and feature branches. I do:

git checkout feature
git rebase master

I got a merge conflict:

Unmerged paths:
(use "git reset HEAD <file>..." to unstage)
(use "git add <file>..." to mark resolution)

    both modified:   /src/...

I run the mergetool

git mergetool

The conflict is nasty and my mergetool is no help. So I need to resolve it manually, so I close the merge tool and I answer:

Was the merge successful [y/n]? N
Continue merging other unresolved paths [y/n]? Y

It was the only conflict, so we exit

Now I expect to see 4 files: REMOTE, LOCAL, BASE, BACKUP around the file with the conflict, but I don't see them.

Question:

  • How do I get to see REMOTE LOCAL BASE and BACKUP while doing rebasing?
Trident D'Gao
  • 18,973
  • 19
  • 95
  • 159
  • 1
    You can run `git mergetool` again (maybe using a standard mergetool, e.g. `vimdiff`) and save the temporary BASE, LOCAL, and REMOTE files that `git mergetool` generates – Leon Oct 10 '17 at 14:20
  • 1
    Git does not create the 4 files you are expecting. They may be created by your mergetool. So I guess these files are not there if you don't use the mergetool. Git adds conflict marks in the merged files. You can open the file, deal with the conflict parts. Keep what you need and remove what you don't. Save and exit, then run `git add` and `git rebase --continue`. – ElpieKay Oct 10 '17 at 14:20
  • @ElpieKay see my own answer – Trident D'Gao Oct 10 '17 at 14:48

1 Answers1

1

so turns out git itself DOES generate all these files, all you need to do is to terminate the merge process (rather than closing it gently answering all questions):

Was the merge successful [y/n]? 

Hit Ctrl + C, then do

git status

Observe

Untracked files:
(use "git add <file>..." to include in what will be committed)

    scripts/src/models/editing/main/basic-block/block-object-attribute-fields_BACKUP_9504.tsx
    scripts/src/models/editing/main/basic-block/block-object-attribute-fields_BASE_9504.tsx
    scripts/src/models/editing/main/basic-block/block-object-attribute-fields_LOCAL_9504.tsx
    scripts/src/models/editing/main/basic-block/block-object-attribute-fields_REMOTE_9504.tsx
Trident D'Gao
  • 18,973
  • 19
  • 95
  • 159
  • Note that each of these various files is actually just a file that was committed at some point, extracted to a new name by the `git mergetool` code. You might want to review my (long) answer to https://stackoverflow.com/q/44212642/1256452 as well (it's about `git merge` rather than `git rebase`, but when rebase needs to do a merge, it invokes the same merge code, and leaves the same kind of index entries in place). – torek Oct 10 '17 at 15:02
  • Independent of all of the above, I recommend setting `merge.conflictStyle` to `diff3`, so that the marked-up file Git leaves behind during low level conflicts contains lines from all three versions (called base, local, and remote here; base, `--ours`, and `--theirs` elsewhere). – torek Oct 10 '17 at 15:06