确保您已经进行了一些更改。否则,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
命令是你用来检查这些变化的。我通常将它们别名为git unstaged
, git staged
, 并将git both
其添加到我的~/.gitconfig
:
[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