当我执行gitdiffCOMMIT时,我看到了提交和HEAD之间的变化(据我所知),但我希望看到单个提交所做的变化。

我还没有在diff/log上找到任何明显的选项来提供输出。


当前回答

gitshow显示了最近一次提交中所做的更改。它相当于git show HEAD。

git show HEAD~1会让您返回一次提交。

其他回答

检查完整更改:

  git diff <commit_Id_1> <commit_Id_2>

仅检查更改/添加/删除的文件:

  git diff <commit_Id_1> <commit_Id_2> --name-only

注意:对于检查diff而不在两者之间进行提交,您不需要输入提交id。

首先使用,

git log #to list all

Or

git log -p -1 #last one commit id

复制提交id。

现在我们使用两种方法列出特定提交的更改,

方法1:

git diff commit_id ^#提交id类似于1c6a6000asad012

方法2:

git show commit_id
For example: git show 1c6a600a

如果在图形视图中检查源更改,请使用:

gitk (your commit id goes here)

例如:

gitk HEAD~1 
git difftool COMMIT^ <commit hash>

如果您配置了difftool,也可以使用。

请参阅此处如何配置difftool。或此处的手册页。

此外,您可以使用git diff树--no commit id--name only-r<commit hash>来查看在给定的提交哈希中更改/提交了哪些文件。

从git diff(1)的手册页:

git diff [options] [<commit>] [--] [<path>…]
git diff [options] --cached [<commit>] [--] [<path>…]
git diff [options] <commit> <commit> [--] [<path>…]
git diff [options] <blob> <blob>
git diff [options] [--no-index] [--] <path> <path>

使用中间的第三个:

git diff [options] <parent-commit> <commit>

同样从同一手册页底部的示例部分:

$ git diff HEAD^ HEAD      <3>

比较上次提交和上次提交之前的版本。

诚然,它的措辞有点混乱,但也不会那么混乱

将最近的提交与之前的提交进行比较。