问题描述
当我执行 git diff COMMIT
时,我会看到该提交和 HEAD 之间的更改(据我所知),但我想查看该单次提交所做的更改.
When I do git diff COMMIT
I see the changes between that commit and HEAD (as far as I know), but I would like to see the changes that were made by that single commit.
我没有在 diff
/log
上找到任何明显的选项来给我那个输出.
I haven't found any obvious options on diff
/ log
that will give me that output.
推荐答案
查看特定 COMMIT
哈希的差异,其中 COMMIT
是提交的哈希:
To see the diff for a particular COMMIT
hash, where COMMIT
is the hash of the commit:
git diff COMMIT~ COMMIT
会告诉你 COMMIT
的祖先和 COMMIT
之间的区别.有关命令的详细信息和 gitrevisions 关于 ~
符号及其朋友.
git diff COMMIT~ COMMIT
will show you the difference between that COMMIT
's ancestor and the COMMIT
. See the man pages for git diff for details about the command and gitrevisions about the ~
notation and its friends.
或者,git show COMMIT
会做一些非常相似的事情.(提交的数据,包括其差异 - 但不适用于合并提交.)请参阅 git show 手册页.
Alternatively, git show COMMIT
will do something very similar. (The commit's data, including its diff - but not for merge commits.) See the git show manpage.
(还有 git diff COMMIT
会告诉你 COMMIT
和 head 之间的区别.)
(also git diff COMMIT
will show you the difference between that COMMIT
and the head.)
这篇关于如何查看 Git 提交中的更改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!