4

We use the feature branch style in git. This means we open a branch, work on it, merge and then delete the branch (the default in applications like Bitbucket, which we use). We have a few developers and a complex tree. I would like to be able to show something specific on the tree. If i check the GUI generated log from tortoise-git i can see this:

enter image description here

The red line indicated is a feature branch that had several developers working on it. As an important note, it excludes commits that are coming from other merges (the red squares in the image).

I would like to be able to show only the commits that appear on this line (merges commits included, but not commits from before the first side of the merge), as a list in the git terminal. How can I do this?

I would have thought something like git log --second-parent (if it existed) would do the trick. Obviously tortoise-git can identify these commits, what is the command to do the same?


Things that don't work:

git log Commit-Where-Branch-Started..Commit-Where-Branch-Merged
As above but with --branches
Karol Dowbecki
  • 43,645
  • 9
  • 78
  • 111
Fantastic Mr Fox
  • 32,495
  • 27
  • 95
  • 175
  • What in your log example at the end is "not working"? – Romain Valeri Mar 11 '19 at 16:12
  • @RomainValeri It shows all the commits, including ones that come in from the merge. I only want the feature branch including any merge commits, but not the individual commits that come from that merge. – Fantastic Mr Fox Mar 11 '19 at 16:15

2 Answers2

2
git log --first-parent  $merge^2

with $merge being any way of spelling the merge commit, git's msg-search syntax can be handy, since merge messages are generally "Merge branch 'red'",

redmerge=`git rev-parse :/Merge branch 'red'"`
git log --first-parent  $redmerge^2

or probably

git log --first-parent  $(git rev-parse ":/'red'")^2

or just c&p the hash code off an exploratory log result. I'm guessing tortoise doesn't back its pretty pictures with any data you can copy from, though if it used SVG for display it could, have you tried rclicking on the top red square to see if it'll let you copy the commit id?

jthill
  • 55,082
  • 5
  • 77
  • 137
1

Assuming you still have the deleted commits in the local reflog you could recreate the branch as explained in this answer:

git checkout -b <branch> <sha>

And then compare with the branch that was used for branching:

git log master..
Karol Dowbecki
  • 43,645
  • 9
  • 78
  • 111