git 记录 1 个分支与另一个分支之间的差异

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11676210/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 14:14:21  来源:igfitidea点击:

git log the difference between 1 branch from another

gitgit-mergegit-log

提问by Adam Johnson

I have 2 branches A and B.

我有 2 个分支 A 和 B。

Whenever I run a build, Branch A gets merged into Branch B. I want to be able to email out all the updates made in A, since the last time the build was ran. How can I use git logto be able to copy all the commits made in A since the last A -> B merge?

每当我运行构建时,分支 A 都会合并到分支 B。我希望能够通过电子邮件发送自上次运行构建以来在 A 中所做的所有更新。我如何才能git log复制自上次 A -> B 合并以来在 A 中所做的所有提交?

回答by che

That'll be

那会

git log B..A

E.g. "display all commits that are in A but not in B" Or if you wish to do it against non local branches

例如“显示在 A 但不在 B 中的所有提交”或者如果您希望针对非本地分支执行此操作

git log origin/B..origin/A

回答by Erik Aybar

An alternative syntax would be to use:

另一种语法是使用:

$ git log refA refB --not refC

or in your case of comparing only two branches

或者在您只比较两个分支的情况下

$ git log A --not B

Also from the GIT SCM Commit Ranges Docs

同样来自GIT SCM Commit Ranges Docs

When comparing two branches it really comes down to preference. I just find this a bit more readable and don't have to worry about confusing A...Bwith A..B(also mentioned in the docs).

当比较两个分支时,它确实归结为偏好。我只是觉得这更具可读性,不必担心A...BA..B(也在文档中提到)混淆。