简体   繁体   English

git diff和git difftool有什么区别?

[英]What is the difference between `git diff` and `git difftool`?

What is the difference between git diff and git difftool ? git diffgit difftool什么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. 我看到可以编辑git的配置文件,以轻松更改调用git difftool时使用的外部工具,而且git diff似乎将修补程序输出到命令行。

Why would I want to use git diff ? 为什么我要使用git diff

As you and WKPlus said, git difftool will use an external tool, while git diff will show the diff directly in the terminal. 正如您和WKPlus所说, git difftool将使用外部工具,而git diff将直接在终端中显示diff。

To answer your last question about when you would want to use git diff , you can think some of these ones : 要回答有关何时使用git diff的最后一个问题,可以考虑以下一些问题:

  1. You do not have a GUI, so you can only use a terminal output 您没有GUI,因此只能使用终端输出
  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. 可以想象很多其他示例,也许您会每天使用git自己找到其中一些。

git difftool will show you the diff in some tool (for example: vimdiff) and allow you to edit directly. git difftool将在某些工具(例如:vimdiff)中显示差异,并允许您直接进行编辑。

If you only want to check the changes you just did, I think git diff is more convenient. 如果您只想检查刚刚所做的更改,我认为git diff更加方便。

It seems like since use vim can read a file and then why I want to use cat ? 好像因为使用vim可以读取文件,然后为什么要使用cat

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM