确保您已经暂存了一些更改。否则,git commit -v
将向您显示与您发布的类似的块,但不会执行任何操作。您可以使用git add
手动暂存更改,或者如果文件已经有版本记录,则可以使用git commit -a -v
暂存并提交更改。
例如:
$ echo "more foo" >> foo.txt
$ git commit -v
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: foo.txt
#
no changes added to commit (use "git add" and/or "git commit -a")
通过使用 git commit -v
命令,可以将变更进行分阶段并展示差异:
:: git add foo.txt
:: GIT_EDITOR=cat git commit -v
# 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:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: foo.txt
#
diff --git a/foo.txt b/foo.txt
index 257cc56..a521556 100644
--- a/foo.txt
+++ b/foo.txt
@@ -1 +1,2 @@
foo
+more foo
Aborting commit due to empty commit message.
如果你只想看到未被提交的更改,使用git diff
命令,如果想看到已准备提交的更改,使用git diff --cached
命令,或者使用git diff HEAD
命令来查看工作树中已暂存和未暂存的更改。
更新:鉴于您的编辑,您确实需要上述git diff
衍生命令。我不确定Aptana Studio是如何工作的。它可能不遵循典型的命令行git流程。在命令行上,您需要暂存修改,然后再提交。上述git diff
命令可以用来检查这些修改。我通常通过将以下内容添加到我的~/.gitconfig
文件来为它们设置别名:git unstaged
、git staged
和git both
。
[alias]
# show difference between working tree and the index
unstaged = diff
# show difference between the HEAD and the index
staged = diff --cached
# show staged and unstaged changes (what would be committed with "git commit -a")
both = diff HEAD