发现当前版本和最新版本之间的差异?
使用git,你怎么能找到当前版本和最新版本之间的区别?
Using git, how can you find the difference between the current and the last versions?
git diff last version:HEAD
我不太了解last版本。
I don't really understand the meaning of "last version".
因为前面的提交可以用HEAD ^访问,所以我认为你正在寻找类似的东西:
As the previous commit can be accessed with HEAD^, I think that you are looking for something like:
git diff HEAD^ HEAD
1.8.5, @
是 HEAD
的别名,因此您可以使用:
As of Git 1.8.5, @
is an alias for HEAD
, so you can use:
git diff @~..@
The following will also work:
git show
如果您想知道头和任何提交之间的区别,您可以使用:
If you want to know the diff between head and any commit you can use:
git diff commit_id HEAD
这会启动你的视觉差异工具(如果已配置):
And this will launch your visual diff tool (if configured):
git difftool HEAD^ HEAD
因为与HEAD的比较是默认的,所以可以忽略它(正如 Orient ):
Since comparison to HEAD is default you can omit it (as pointed out by Orient):
git diff @^
git diff HEAD^
git diff commit_id
警告
- @ScottF和@Panzercrisis在注释中解释说,在Windows上必须使用
〜
字符而不是^
。 - @ScottF and @Panzercrisis explain in the comments that on Windows the
~
character must be used instead of^
.