如何查看 Git 提交中的更改? [英] How can I see the changes in a Git commit?

查看:29
本文介绍了如何查看 Git 提交中的更改?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我执行 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 提交中的更改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆