本文介绍了查找当前版本与上一版本之间的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Git,如何找到当前版本与最新版本之间的区别?

Using Git, how can you find the difference between the current and the last version?

git diff last version:HEAD

推荐答案

我不太了解最新版本"的含义.

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

从Git 1.8.5开始,@HEAD的别名,因此您可以使用:

As of Git 1.8.5, @ is an alias for HEAD, so you can use:

git diff @~..@

以下内容也将起作用:

git show

如果您想知道head和任何提交之间的区别,可以使用:

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进行比较,因此您可以省略它( Oriental 指出)

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上必须使用~字符代替^.
  • Warnings

    • @ScottF and @Panzercrisis explain in the comments that on Windows the ~ character must be used instead of ^.
    • 这篇关于查找当前版本与上一版本之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 20:30
查看更多