Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 365
Adam Johnson Avatar asked Jul 26 '12 18:07

Adam Johnson


People also ask

How do I compare two branches in github?

On the Github, go to the Source view of your project. You will see a link named 'Branch List'. Once the page opens you can see a list of all the remote branches. Hit on the Compare button in front of any of the available branches to see the difference between two branches.

How do I find the difference between two commits in git?

To see the changes between two commits, you can use git diff ID1.. ID2 , where ID1 and ID2 identify the two commits you're interested in, and the connector .. is a pair of dots. For example, git diff abc123.. def456 shows the differences between the commits abc123 and def456 , while git diff HEAD~1..


2 Answers

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 
like image 134
che Avatar answered Oct 25 '22 15:10

che


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).

like image 22
Erik Aybar Avatar answered Oct 25 '22 14:10

Erik Aybar