ChatGPT解决这个技术问题 Extra ChatGPT

git log the difference between 1 branch from another

I have 2 branches A and 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 log to be able to copy all the commits made in A since the last A -> B merge?


D
Daniel Sokolowski

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

git log origin/B..origin/A

@Jakub I think the proper link is now git-scm.com/book/en/v2/…
How to apply the commit from the git log output so that both branch will have same commits?
d
dotnix

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

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...B with A..B (also mentioned in the docs).