我如何获得这两个git提交之间的interdiff? [英] How do I get the interdiff between these two git commits?

查看:99
本文介绍了我如何获得这两个git提交之间的interdiff?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图查看git中相同提交的两个修订之间的差异。基本上差异的差异。从迄今为止我读到的,这被称为interdiff。我已经阅读了几篇关于如何创建git补丁interdiffs的教程,但是我还没有能够让这些方法在我的特殊情况下工作。



设置。我有两个不同的分支,每个都有略微不同的提交:

  * 29e734f  - (origin / feature_branch,new_commits)新提交3 69分钟前)< Ajedi32> 
* b22ebea - 新提交2(89分钟前)< Ajedi32>
* 09d42c2 - 新提交1(2小时前)< Ajedi32>
| * 467e08f - (old_commits)旧提交3(4周前)< Ajedi32>
| * f2bf1cb - 旧提交2(4周前)< Ajedi32>
| * 34a2187 - 旧承诺1(4周前)< Ajedi32>
| /
* 1b05a4a - (origin / base,base)基本提交(5周前)< Ajedi32>

在这个例子中,我想找到Old commit 3和New commit 3之间的interdiff 。我试着从这两个提交中创建一个补丁文件,并通过 interdiff 工具运行它们,但我得到的只是这个:

  2个hunk中的1个失败 - 将拒绝文件保存到文件/tmp/interdiff-1.Kgwx8u.rej 
interdiff:将patch1应用于重建文件$ b时出错$ b

我不确定这意味着什么,所以我现在被卡住了。我从哪里出发?



注意:我是不是正在寻找 git diff old_commits new_commits code>这里。我不希望对输出中包含的提交1和2进行修改。 可能是这样的:

>

  git log -p -1 new_commits> patch.new 
git log -p -1 old_commits> patch.old
diff patch.old patch.new

或者对于简单的单线程( bash ):

  diff <(git log -p -1 old_commits)<(git log -p -1 new_commits)


I'm trying to view the difference between two revisions of the same commit in git. A diff of the diffs, basically. From what I've read so far, this is known as the "interdiff". I've read several tutorials on how to create interdiffs of git patches, but I haven't been able to get these methods to work in my particular case.

So here's the setup. I have two diverging branches, each with slightly different commits:

* 29e734f - (origin/feature_branch, new_commits) New commit 3 (69 minutes ago) <Ajedi32>
* b22ebea - New commit 2 (89 minutes ago) <Ajedi32>
* 09d42c2 - New commit 1 (2 hours ago) <Ajedi32>
| * 467e08f - (old_commits) Old commit 3 (4 weeks ago) <Ajedi32>
| * f2bf1cb - Old commit 2 (4 weeks ago) <Ajedi32>
| * 34a2187 - Old commit 1 (4 weeks ago) <Ajedi32>
|/  
*   1b05a4a - (origin/base, base) Base commit (5 weeks ago) <Ajedi32>

In this example, I want to find the interdiff between "Old commit 3" and "New commit 3". I've tried creating a patch file from these two commits and running them through the interdiff utility, but all I got was this:

1 out of 2 hunks FAILED -- saving rejects to file /tmp/interdiff-1.Kgwx8u.rej
interdiff: Error applying patch1 to reconstructed file

I'm not really sure what that means, so I'm kind of stuck now. Where do I go from here?

Note: I'm am not looking for git diff old_commits new_commits here. I don't want the revisions to commits 1 and 2 included in the output.

解决方案

Perhaps something like this:

git log -p -1 new_commits > patch.new
git log -p -1 old_commits > patch.old
diff patch.old patch.new

Or for a terse one-liner (in bash):

diff <(git log -p -1 old_commits) <(git log -p -1 new_commits)

这篇关于我如何获得这两个git提交之间的interdiff?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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