Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup the git mergetool with the --dir-diff option?

Tags:

git

difftool has a great user friendly option for viewing diffs. Its the --dir-diff option - allowing you to abritrarly browse through two directories.

The git mergetool has a very clumsy and unfriendly userinterface. Solving merge conflicts has to be done in a strict order given by git.

Is there a possibility to setup a similar option like $ git difftool --dir-diff? say $ git mergetool --dir-merge calling the directory compare of e.g. winmerge? Or do one has an alternativ solution to provide a user friendly interface for solving multiple file merge conflicts?

like image 348
Jurg Zbinden Avatar asked Apr 01 '13 11:04

Jurg Zbinden


2 Answers

There is a simple Python program called meld, but anything that visualises merges with three panes will do.

To use it for merge resolution, have it installed and, while in an unresolved-merge in git, type: $ git mergetool.

More on a topic you can read at: Painless Merge Conflict Resolution in Git

...I have found that the tools and interfaces available for performing merges do not equip programmers sufficiently to do them effectively. Often, a programmer will simply run git merge and hope that git will take care of the large majority of the hunks. Of the hunks that conflict, the usual merge strategy of the human at the helm is to use the surrounding context to roughly guess what the intended program is supposed to look like.

This article will hopefully demonstrate that there can be a much more measured process to the resolution of merge conflicts which takes the guesswork out of this risky operation...

like image 193
r4M0 Avatar answered Nov 15 '22 10:11

r4M0


You can pass in a list of files to git mergetool'

To get a list of unmerged files, you can use git ls-files --unmerged $DIR'

In summary, do

git mergetool `git ls-files --unmerged $DIR`
like image 39
deterb Avatar answered Nov 15 '22 11:11

deterb