Miserable Variable
Miserable Variable

Reputation: 28752

List changes in master since a branch was created

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?

Upvotes: 0

Views: 39

Answers (2)

user456814
user456814

Reputation:

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.

Upvotes: 2

Jonathan Wakely
Jonathan Wakely

Reputation: 171253

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

Upvotes: 1

Related Questions