0

A branch, called mil-1 (for milestone) was created from master some time ago. There have been changes to master since this branch was created. I need to review them and merge some of them into the milestone branch.

After running git fetch --all, git log refs/heads/master lists the changes in master; and I know how to restrict them to a certain number of commits:

$ git log -1 origin/master
commit 5401cc7edf382183537a011632c422a491faea5b
Author: ********
Date:   Wed May 28 18:29:59 2014 +0530

But how do I restrict the output to only to commits done after the mil-1 branch was created?

Miserable Variable
  • 28,432
  • 15
  • 72
  • 133
  • Possibly related: [Using Git, show all commits that are in one branch, but not the other(s)](http://stackoverflow.com/q/1710894/456814). –  May 28 '14 at 17:00

2 Answers2

2

Assuming that mil-1 hasn't been updated with the new commits made to master, then this is done using a simple commit range:

git log mil-1..origin/master

will show you all commits that exist in the origin/master that don't yet exist in mil-1.

See also Pro Git § 6.1 Git Tools - Revision Selection: Commit Ranges.

1

But how do I restrict the output to only to commits done after the mil-1 branch was created?

First you can use git merge-base to find the most recent commit the two branches have in common (which in your case is probably the commit that the branch was created from):

mergebase=$( git merge-base master mil-1 )

Then you can list all commits on the master branch since then:

git log $mergebase..master

Alternatively, you get the same result just asking for all commits between mil-1..master, which tells you all the commits which are in the history of master but not in the history of mil-1

Jonathan Wakely
  • 166,810
  • 27
  • 341
  • 521