Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git mergetool vs difftool

Tags:

git

I've read the man pages for mergetool and difftool but I guess I'm still not clear on the general differences between the two. They both call up a merge tool of some sort, right? The point of running a diff is to merge, right?

What's the layman's descriptions for each of these directives?

update: I guess I need to expand on this question. Yes... one says diff. The other one says merge. But what is the purpose/use of running a diff? Can you decide, upon seeing the diff, that you want to go ahead and merge? Are diff tools generally the same tools you run for merges? If you run mergetool and then canceled the merge, didn't you just essentially do what difftool did?

like image 320
Jeremy Ricketts Avatar asked Jun 25 '12 21:06

Jeremy Ricketts


People also ask

What is Mergetool in git?

DESCRIPTION. Use git mergetool to run one of several merge utilities to resolve merge conflicts. It is typically run after git merge. If one or more <file> parameters are given, the merge tool program will be run to resolve differences on each file (skipping those without conflicts).

What is Difftool in git?

git difftool is a Git command that allows you to compare and edit files between revisions using common diff tools. git difftool is a frontend to git diff and accepts the same options and arguments.

What is the default git diff tool?

The default Diff Tool is vimdiff. Specifying a Diff Tool affects the git difftool command. The command git diff still performs diffing on the command-line.


1 Answers

They are two different operations, and you could technically have two different programs configured (in the Git world, at least) to perform each operation.

  • DIFF - you want to see the differences between two files (or more, and/or folder structures)
  • MERGE - you want to see the differences between two (or more) files and try to merge them together into a single output file

The MERGE might show DIFFs as part of it's working, but they are separate things. A lot of diff programs have blurred the lines over the years and started to handle merging as well.

like image 125
Nicholas Head Avatar answered Oct 06 '22 00:10

Nicholas Head