Reputation: 34673
If I end up in more complicated conflict during a rebase or other merge situation, I'd create a "mine" and "theirs" files and make a visual diff with my IDE. Then I would start manually fixing the differences until the files become "equal" and I would copy over the changes to the conflicting file and git add
it, instead of reading and deleting <<<<< HEAD >>>>>>>
and <<<<< current commit >>>>>
sections.
Is there a way to automate the part with creating "mine" and "theirs" files? I just want two files with two distinctive names in the same dir, instead of having to checkout them based on commit versions on my own.
Upvotes: 3
Views: 109
Reputation: 13616
Running
git mergetool
does exactly what you want. All you have to do is configure the merge tool you want to use (see man git-mergetool
for the details).
It has built-in support for kdiff3
, vimdiff
(in three different modes) and other nice tools and you can extend it to use your IDE as a merge tool.
Upvotes: 1
Reputation: 60295
To answer the question as asked, you want git checkout-index --stage=
. Stage 1 is the merge base, the version where the two histories diverged. Stage 2 is yours, stage 3 is theirs. You can git checkout-index --stage=all myfile
and it'll print the names it invented for each, e.g.
$ git checkout-index --stage=all file.txt
.merge_file_a01172 .merge_file_b01172 .merge_file_c01172 file.txt
Having the original around for comparison can be good.
Upvotes: 2