Operations like Merge and Diff are the most irritating & tricky tasks via command line when working on large code changes. So let us see how can we add some graphical stuff for these operations when using on GIT so that we can do merging and other options very easily.
By following below steps you can install and configure diffmerge tool for git.
- Based on the operating system you are using download respective diffmerge tool.
- Now go to the source code directory which have been cloned from a git repository. Add the following commands to make git support diffmerge in diff and merge operations.
git config --global diff.tool diffmerge git config --global difftool.diffmerge.cmd 'diffmerge "$LOCAL" "$REMOTE"' git config --global merge.tool diffmerge git config --global mergetool.diffmerge.cmd 'diffmerge --merge --result="$MERGED" "$LOCAL" "$(if test -f "$BASE"; then echo "$BASE"; else echo "$LOCAL"; fi)" "$REMOTE"' git config --global mergetool.diffmerge.trustExitCode true
Now let us see how can we use the diffmerge tool.
Whenever you want to launch diff use difftool and similarly mergetool to launch merge as shown below.
# To diff a local file against the checked-in version git difftool file # to diff the local file against the version in some-feature-branch git difftool some-feature-branch file # to diff the file under the Build-54 tag to the Build-55 tag git difftool Build-54..Build-55 file # to do merge operations and resolve conflicts via diffmerge tool use below command. git mergetool
Start using it now.