Tarun Gupta
Tarun Gupta

Reputation: 1669

Git command to find commits made in branch that are not present in master

Looking for a git command which displays commits in a branch that are not merged to master yet, preferably with hash, date, author name and comment.

(This probably is a duplicate question but I couldn't find it on SO)

Upvotes: 5

Views: 4022

Answers (2)

SzG
SzG

Reputation: 12619

To list commits that are not on master but only only on branch:

git log master..branch

It does not matter which branch is checked out, as you specify the range. Git will find the shortest route from master to branch, first going back on master, not printing the commits, and then listing commits when going forward in history towards branch.

The default format of git log contains all the data you wish to see. But I'd use the --decorate option too, to highlight branches and tags.

Upvotes: 8

user4815162342
user4815162342

Reputation: 154886

Use the ^master syntax to exclude commits visible from master (i.e. those merged to the master branch):

git log branch ^master

The format can be customized using the --format option, e.g. --format="format:%H %ad %an %s"

Upvotes: 4

Related Questions