我在Ubuntu 10.04 (Lucid Lynx)上使用Git。

我已经向我的主人许下了一些承诺。

但是,我想知道这些提交之间的区别。它们都在我的主分支上。

例如:

commit dj374
made changes

commit y4746
made changes

commit k73ud
made changes

我想知道k73ud和dj374的区别。然而,当我执行以下操作时,我无法看到我在k73ud中所做的更改。

git diff k73ud..dj374 > master.patch

当前回答

如果您想查看每次提交时引入的更改,请尝试"git log -p"

其他回答

我使用gitk来查看区别:

gitk k73ud..dj374

它有一个图形用户界面模式,因此审查更容易。

 1. git diff <commit-id> <commit-id>
 2. git diff HEAD^ HEAD     -(HEAD = current branch’s tip),( HEAD^ = version before the last commit)
 3. git diff HEAD^ HEAD — ./file     (comparison to specified file)
 4. git diff HEAD~5 HEAD           - (HEAD~5 refers to the last 5 commits.)

检查pull后最后2次提交的更改最简单:

git diff HEAD~2 

如果您想查看每次提交时引入的更改,请尝试"git log -p"

对于最后两次提交

git diff HEAD~1 HEAD

通过扩展来比较2个提交,例如

git diff HEAD~6 HEAD~3