$ git diff # Default Use$ git diff --cached # Can be used to show difference after adding the files$ git diff --staged # Same as 'git diff --cached' mostly used with latest version of git
示例
$ git diffdiff --git a/x/y/z.js b/x/y/z.js index 98fc22b..0359d84 100644--- a/x/y/z.js+++ b/x/y/z.js @@ -43,7 +43,7 @@ var a = function (tooltip) {
- if (a)+ if (typeof a !== 'undefined')res = 1;elseres = 2;
$ git add x/y/z.js$ git diff$
添加文件后,您不能使用默认的'git diff'。您必须这样做:-
$ git diff --cacheddiff --git a/x/y/z.js b/x/y/z.js index 98fc22b..0359d84 100644--- a/x/y/z.js+++ b/x/y/z.js @@ -43,7 +43,7 @@ var a = function (tooltip) {
- if (a)+ if (typeof a !== 'undefined')res = 1;elseres = 2;