在提交之间显示差异 [英] Show diff between commits

查看:70
本文介绍了在提交之间显示差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



我向主人做了一些提交。

然而,我想获得差异在这些提交之间。所有这些都在我的主分支上。



例如:

 提交dj374 
进行更改
$ b $提交y4746
进行更改

提交k73ud
进行更改

我想要了解k73ud和dj374的区别。但是,当我做了以下操作时,我无法看到我在 k73ud 中所做的更改。

  git diff k73ud..dj374> master.patch 


解决方案

b

  git diff k73ud ^ .. dj374 

确保在结果差异中包含 k73ud 的所有更改。

git diff 比较两个端点(代替提交范围)。
由于OP希望看到由 k73ud 引入的更改,他/她需要区分第一个父代提交 k73ud k73ud ^ (或 k73ud ^ 1 k73ud〜 <这样, diff 结果将包含自 开始的更改 k73ud 父级(意指包括 k73ud 本身的变化),而不是自 code> k73ud (高达 dj374 )。


I am using Git on Ubuntu 10.04 (Lucid Lynx).

I have made some commits to my master.

However, I want to get the difference between these commits. All of them are on my master branch.

For example:

commit dj374
made changes

commit y4746
made changes

commit k73ud
made changes

I want to get the difference between k73ud and dj374. However, when I did the following I couldn't see the changes I made in k73ud.

git diff k73ud..dj374 > master.patch

解决方案

Try

git diff k73ud^..dj374

to make sure to include all changes of k73ud in the resulting diff.

git diff compares two endpoints (instead of a commit range). Since the OP want to see the changes introduced by k73ud, he/she needs to difference between the first parent commit of k73ud: k73ud^ (or k73ud^1 or k73ud~).

That way, the diff results will include changes since k73ud parent (meaning including changes from k73ud itself), instead of changes introduced since k73ud (up to dj374).

这篇关于在提交之间显示差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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