Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between `git diff` and `git difftool`?

Tags:

git

What is the difference between git diff and git difftool?

I see that I can edit the configuration file for git to easily change the external tool used when I invoke git difftool and it seems that git diff outputs patches to the command line.

Why would I want to use git diff?

like image 743
vmrob Avatar asked Jan 06 '14 12:01

vmrob


2 Answers

As you and WKPlus said, git difftool will use an external tool, while git diff will show the diff directly in the terminal.

To answer your last question about when you would want to use git diff, you can think some of these ones :

  1. You do not have a GUI, so you can only use a terminal output
  2. You do not have an external tool
  3. You do not want to launch a "heavy" external tool and just want to quickly check the diff between two versions

Many other example can be imagined, and maybe you will find some of them yourself using git on daily basis.

like image 86
mithrop Avatar answered Sep 18 '22 14:09

mithrop


git difftool will show you the diff in some tool (for example: vimdiff) and allow you to edit directly.

If you only want to check the changes you just did, I think git diff is more convenient.

It seems like since use vim can read a file and then why I want to use cat?

like image 30
WKPlus Avatar answered Sep 18 '22 14:09

WKPlus