git status 显示你上次提交更新后的更改或者写入缓存的改动, 而 git diff 一行一行地显示这些改动具体是啥。

接下来我们来查看下 git diff --cached 的执行效果:

$ git add hello.php
$ git status -s
A  README
A  hello.php
$ git diff --cached
diff --git a / README b / README
new file mode 100644
index 0000000..8f87495
--- / dev / null
+++ b / README
@@ - 0 , 0 + 1 @@
+ # Runoob Git 测试
diff --git a / hello.php b / hello.php
new file mode 100644
index 0000000..69b5711
--- / dev / null
+++ b / hello.php
@@ - 0 , 0 + 1 , 3 @@
+ < ?php
+ echo '菜鸟教程:www.runoob.com' ;

Git 基本操作 Git 基本操作