获取多个非连续提交的累积git diff [英] Get a cumulative git diffs for multiple non-consecutuve commits

查看:58
本文介绍了获取多个非连续提交的累积git diff的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有一种方法可以获取多个非连续提交的累积git diff.

I'd like to know if there's a way to get a cumulative git diff for multiple non-consecutive commits.

例如,我可以使用以下命令获得每次提交的更改内容:

For an example, I can get a what changed in each commit using:

git diff 123456^ 123456

其中"123456"是git哈希.

Where "123456" is a git hash.

我可以进行多次提交.但是我现在想做多个比较,然后将输出合并为一个.

I can go this for multiple commits. But I now I want to do multiple diffs and combine the output into one.

例如,

git diff 123456^ 123456
git diff abcdef^ abcdef

但是将diff合并为一个.但是"123456"和"abcdef"不是连续的提交.

But combine the diff into one. But "123456" and "abcdef" are not consecutive commits.

更新:可以说文件xyz中的一行已更改:

Update: Lets say a line in file xyz changed:

In commit 123456: from "foo" to "bar"
in commit abcdef: from "bar" to "oof"

我只想看看在提交之后,它从"foo"变为"oof".

I just want to see that it changed from "foo" to "oof" after these to commits.

git diff 123456 abcdef 对我不起作用,因为我不想在123456和abcdef之间进行所有更改.

git diff 123456 abcdef does not work for me because I don't want to all the changes in between 123456 and abcdef.

我不想做任何事情;只是想以此来查看代码的安全性.

I dont want to commit anything; just want to this to review code for security.

推荐答案

我确信有人有一个更聪明的方法,但是您可以尝试将所有选择的提交压缩为一个,然后对那个进行比较.您可以通过对-no-commit 进行-cherry-pick 来做到这一点.获得最终结果后,您可以 git diff HEAD 来获取基本版本的差异(假设您将自己重置为该位置).

I'm sure someone has a more clever approach, but you could try to squash all your chosen commits down into one and then do the diff on that one. You could do that by doing --cherry-pick with --no-commit. Once you have the final result, you can git diff HEAD to get the diff of that with your base version (assuming you reset yourself to that spot).

这篇关于获取多个非连续提交的累积git diff的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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