Can I make git create two files to merge (mine & theirs) instead of one

If I run into a more complex conflict during a reinstall or other merge situation, I would create "mine" and "mine" files and make a visual diff from my IDE. Then I'll start manually fixing the differences until the files are "equal" and I would copy the changes to the conflicting file and git add

, instead of reading and deleting the sections <<<<< HEAD >>>>>>>

and <<<<< current commit >>>>>

.

Is there a way to automate the "mine" and "theirs" part? I just want two files with two distinguished names in the same directory, instead of checking them out myself based on commit versions.

+3


source to share


2 answers


To answer the question asked you want git checkout-index --stage=

. Stage 1 is the merge base, the version where the two stories diverged. Stage 2 is yours, stage 3 belongs to them. You can git checkout-index --stage=all myfile

, and it will print the names he invented for each, for example.

$ git checkout-index --stage=all file.txt
.merge_file_a01172 .merge_file_b01172 .merge_file_c01172        file.txt

      



Having an original for comparison may be good.

+2


source


Running

git mergetool

      



does exactly what you want. All you have to do is set up the merge tool you want to use (see man git-mergetool

for details).

It has built-in support kdiff3

, vimdiff

(in three different modes) and other useful tools, and you can extend this to use your IDE as a merge tool.

+1


source







All Articles