Git Merge/Git Difftool: Compare a file between two different branches

Moving from Subversion to Git can be hard and i ran into an issue trying to resolve conflicts in a file that was different in the two branches I work on. Since I am working on a Mac, with OSX Lion, i found these two articles to be quite useful:

How to setup Git to use Diffmerge to setup DiffMerge as your Git difftool, for Mac OSX you actually need to set the path to DiffMerge like this:

[difftool]
prompt = NO
[difftool “diffmerge”]
cmd = ~/Applications/DiffMerge.app/Contents/MacOS/DiffMerge “$LOCAL” “$REMOTE” # For DiffMerge

Using DiffMerge as your Git visual merge and diff tool provided some good examples on how to use the command git difftool

# diff the local file.m against the checked-in version
git difftool file.m

# diff the local file.m against the version in some-feature-branch
git difftool some-feature-branch file.m

# diff the file.m from the Build-54 tag to the Build-55 tag
git difftool Build-54..Build-55 file.m

This helped me resolve my issues, DiffMerge is an impressive tool, especially the three way merge, and I heavily recommend it.

Here is a more complete tutorial on merging in DiffMerge.

Advertisement

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: