简体   繁体   English

显示来自选定git提交的组合差异

[英]Show combined diff from selected git commits

I have a repository with a lot of changes. 我的存储库有很多更改。 I want to review changes related to particular issue. 我想查看与特定问题相关的更改。 Those commits are already in the master branch and are interleaved with unrelated commits. 这些提交已经在master分支中,并且与无关的提交交织在一起。 I can identify those interesting commits via specific text in their message. 我可以通过消息中的特定文本来识别那些有趣的提交。 I can also see the individual changes with git diff command. 我还可以使用git diff命令查看各个更改。 However, I would like to see them as single patch: If first commit changed some lines and the second one changed them again, I do not want to see the interim state. 但是,我希望将它们视为单个修补程序:如果第一次提交更改了某些行,而第二次提交又更改了它们,则我不希望看到临时状态。 I also do not want to see any changes from unrelated commits (unless necessary to resolve conflicts). 我也不想看到无关提交的任何更改(除非有必要解决冲突)。

The only way to achieve this I can think of, is to update the whole tree to the state before first commit. 我能想到的唯一方法是在第一次提交之前将整个树更新为状态。 Apply the changes one after another and then git diff working directory against base revision. 依次套用更改,然后对基本修订版本使用git diff工作目录。

However, this won't work, if included commits depend on not-included commits. 但是,如果包含的提交依赖于未包含的提交,则此方法将无效。 Instead of failing or having to manually resolve conflicts, I would prefer to just include necessary changes from other commits. 与其失败或不必手动解决冲突,我不如仅包括其他提交中的必要更改。 The output will be read only by humans, so as long as all the relevant changes are included, I don't care how the conflicts are handled. 输出将仅由人类读取,因此只要包括所有相关更改,我就不会在乎如何处理冲突。

It would also be nice, if I didn't have to stash my local changes before this operation. 如果我不必在执行此操作之前隐藏本地更改,那也很好。

How to avoid those problems and generate such patch? 如何避免这些问题并生成此类补丁?

There's a program called combinediff which should be able to do this; 有一个叫做combinediff的程序应该可以做到这一点。 make a diff for each change you care about, then feed them all to combinediff . 对您关心的每个更改进行比较,然后将它们全部喂入combinediff It's part of the patchutils package, which on Linux is typically available via your distribution's package manager. 它是patchutils软件包的一部分,在Linux上通常可以通过发行版的软件包管理器获得。 The source is located at https://github.com/twaugh/patchutils . 源码位于https://github.com/twaugh/patchutils

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM