1

How can I get all commit messages of feature branch after merge (eg. to "develop" branch)?

I tried:

git log testbranch...develop --pretty=oneline

but it doesn't work.

Tree: enter image description here

"Commit1" and "Commit2" are commits of "testbranch" which is already merged into develop.

Majkeee
  • 960
  • 1
  • 8
  • 28
JaSHin
  • 211
  • 2
  • 16
  • 43

1 Answers1

1

You can, for the simple case, list commits accessible from testbranch, but not from develop:

git log testbranch ^develop --no-merges --pretty=oneline

That should be the same as develop..testbranch (two dots, not three)
See:

If testbranch has been merged back to develop, especially in a fast-forward manner, an empty result is expected.
Meaning: once a branch has been fast forwarded into another, there is no stating point anymore:

d---d--t--t--t (testbranch)
    |
(develop)

git checkout develop
git merge testbranch

d--d--t--t--t (testbranch, develop)

You don't know anymore "where" testbranch started.

If you did branch out with testbranch yourself (that is, in your local repo) not too long ago (less than 90 days), you can check out the git reflog output, to get back a trace of the new testbranch event at <sha1>.
See "How do I check git log for a “fast-forward” merge?".
Try:

git reflog show testbranch

Then, knowing where that branch started, you can list the commits with:

git log develop ^<sha1>

In your case, you might "know" that testbranch started at commit1, but my point is: Git alone would not know that (except locally in the reflog, if that branch was created in said local repo)

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I tried `git log testbranch..develop --no-merges --pretty=oneline` but output is empty. – JaSHin Jul 15 '17 at 14:50
  • And `testbranch ^develop`? Should be empty too. Don't forget your question mentions `master`, not `develop`. And do you see commits in `testbranch` which are not in develop? Does `git branch -vv` lists local branches (not remote tracking branches) `testbranch` *and* `develop`? – VonC Jul 15 '17 at 14:52
  • Yes `testbranch ^develop` is empty too. Testbranch is merged to develop (I add image to my question). Result of `git branch -vv` contains both branches. – JaSHin Jul 15 '17 at 14:56
  • @JaSHin Yes, if that branch is merged to develop, an empty result is expected. – VonC Jul 15 '17 at 14:58
  • Is there a way to get commit messages after merge? – JaSHin Jul 15 '17 at 15:00
  • @JaSHin I don't see any commit after merge in develop. Do you see any commit you want to list in your tree? – VonC Jul 15 '17 at 15:05
  • d394f82 is last commit. I need result with "Commit1" and "Commit2". Testbranch started with "Commit1". – JaSHin Jul 15 '17 at 15:07
  • @JaSHin I have edited my answer to explain where to find where Testbranch started. – VonC Jul 15 '17 at 15:15