/* Ajith - Syntax Higlighter - End ----------------------------------------------- */

7.11.2012

GIT - Adding diffmerge as visual merge in git

GIT is one of the popular distributed code repositories in opensource community, especially with developers working on opensource projects like linux kernel and others.

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.
  1. Based on the operating system you are using download respective diffmerge tool.

  2. 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.
  3. 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
Configuration is done.

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.

References 

1. Twobit Labs

No comments :

Post a Comment

Your comments are moderated