How to get the changes on a branch in git
        Posted  
        
            by Greg Hewgill
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Greg Hewgill
        
        
        
        Published on 2008-09-10T07:44:53Z
        Indexed on 
            2010/05/14
            0:44 UTC
        
        
        Read the original article
        Hit count: 428
        
What is the best way to get a log of commits on a branch since the time it was branched from the current branch? My solution so far is:
git log $(git merge-base HEAD branch)..branch
The documentation for git-diff indicates that "git diff A...B" is equivalent to "git diff $(git-merge-base A B) B". On the other hand, the documentation for git-rev-parse indicates that "r1...r2" is defined as "r1 r2 --not $(git merge-base --all r1 r2)". Why are these different? Note that "git diff HEAD...branch" gives me the diffs I want, but the corresponding git log command gives me more than what I want.
In pictures, suppose this:
         x---y---z---branch
        /
---a---b---c---d---e---HEAD
I would like to get a log containing commits x, y, z. "git diff HEAD...branch" gives these commits. However, "git log HEAD...branch" gives x, y, z, c, d, e.
© Stack Overflow or respective owner