2015-11-18 71 views
3

我后的目标是调用,例如,git diff --verbose(错误:无效选项)来获取你打电话时git commit --verbose得到相同的输出:如何通过`git diff`获取`git commit --verbose`输出?

# Please enter the commit message for your changes. Lines starting 
# with '#' will be ignored, and an empty message aborts the commit. 
# On branch master 
# Changes to be committed: 
# modified: README.md 
# 
# Untracked files: 
# .gitignore 
# 
# ------------------------ >8 ------------------------ 
# Do not touch the line above. 
# Everything below will be removed. 
diff --git a/README.md b/README.md 
index 267d5e2..b5f70de 100644 
--- a/README.md 
+++ b/README.md 
@@ -1,3 +1,4 @@ 

-# Sandbox 
+# SANDBOX 

+Some new text 

我发现git diff --patch-with-stat这是如此接近但是输出结果并不那么友好,并且不会显示我需要的未跟踪文件。

README.md | 3 ++- 
1 file changed, 2 insertions(+), 1 deletion(-) 

diff --git a/README.md b/README.md 
index 267d5e2..b5f70de 100644 
--- a/README.md 
+++ b/README.md 
@@ -1,3 +1,4 @@ 

-# Sandbox 
+# SANDBOX 

+Some new text 

哪里git diff --verbose?有什么方法通过另一个命令获得与git commit --verbose相同的输出?

回答

1

git diff --patch --stat仍然是最好的选择,但可以从一个附加命令受益:

git ls-files -o 

随着-o,该git ls-files将在输出中显示其他(即未跟踪)文件。