tags:

views:

42

answers:

3

Usually 'git log' shows all the commits contributing to the current point, even those commits that came from branches merged into the current branch.

Is it possible to issue a command to only see the commits in a particular branch? That is, if there is an integration branch where everything is merged just before shipping, is there any git command to see only those commits in that branch?

A: 

I'm not totally sure. The idea of a branch in git is simply a pointer to a location in the tree (not a completely separate line of development like in svn etc.).

You can however do a git branch --no-merged to see what branches need to be integrated into the current one.

I suppose it's possible to write something that will give you all commits which are there only behind the current HEAD and nowhere else. I'm not sure how though.

Noufal Ibrahim
+1  A: 

This should work:

git checkout <branch>
git diff master <commit just before the merge to master>

There should be a way to automate getting the name of the commit just before the merge to master, which would let you make this into a macro or alias.

Also, check out git log -p -m --first-parent as mentioned in the git help log docs; it might do something similar enough.

Ether
`--first-parent` is almost certainly what the OP wants. This will cause the revision tree walking to follow only the first parent of merge commits. When you merge `topic` into `integration`, the (merged-into) commit from `integration` is the first parent, and the (merged) commit from `topic` is the second parent. Assuming you've been consistent about which way you merge, that ought to list the desired commits. (The OP is asking about seeing commits (plural), so it's `log` not `diff` they want.)
Jefromi
+1  A: 

This (which you already know) specifies the set of commits reachable from integration:

g log integration

The "^" operation can be used for everything NOT reachable via this commit (rev). For example, everything reachable by integration and exclude everything also reachable by master:

g log ^master integration

The common shorthand for that (integration but not master):

g log master..integration

You can use multiple exclude specifiers (integration but not master or devel):

g log ^master ^devel integration

Hopefully that covers enough to give you what you need. This information is in man git-rev-parse in the SPECIFYING REVISIONS and SPECIFYING RANGES section.

kanaka