If you'd like to see the staged changes in a diff, you can still use git diff
, you just need to pass the --staged
flag:
david@pav:~/dummy_repo$ echo "Hello, world" > hello.txt
david@pav:~/dummy_repo$ git status
# On branch master
#
# Initial commit
#
# Untracked files:
# hello.txt
nothing added to commit but untracked files present
david@pav:~/dummy_repo$ git add hello.txt
david@pav:~/dummy_repo$ git diff
david@pav:~/dummy_repo$ git diff --staged
diff --git a/hello.txt b/hello.txt
new file mode 100644
index 0000000..76d5293
--- /dev/null
+++ b/hello.txt
@@ -0,0 +1 @@
+Hello, world
If you only care about which files are staged, you can of course do a git status
, but git diff --staged --name-only
will give each staged filename on its own line.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…