怎么比较工作区和暂存区所含文件的差异

  • HEAD 上一次commit的内容,例如readme.md文件中存放1
  • 暂存区 编辑了readme.md,现在文件中存放12并执行了git add readme.md
  • 工作区 继续编辑readme.md,现在文件中存放123
MacBook-Pro-4:git_01 booboo$ vim readme.md
MacBook-Pro-4:git_01 booboo$ git add readme.md
MacBook-Pro-4:git_01 booboo$ git commit -m 'add 1'
[master a95d9b6] add 1
1 file changed, 1 insertion(+), 1 deletion(-)
MacBook-Pro-4:git_01 booboo$ vim readme.md
MacBook-Pro-4:git_01 booboo$ git add readme.md
MacBook-Pro-4:git_01 booboo$ git diff --cached
diff --git a/readme.md b/readme.md
index d00491f..48082f7 100644
--- a/readme.md
+++ b/readme.md
@@ -1 +1 @@
-1
+12
MacBook-Pro-4:git_01 booboo$ vim readme.md
MacBook-Pro-4:git_01 booboo$ git diff
diff --git a/readme.md b/readme.md
index 48082f7..190a180 100644
--- a/readme.md
+++ b/readme.md
@@ -1 +1 @@
-12
+123