2

Similar question to How can I see what I am about to push with git? - I want to see the descriptions (commit messages) of commits that will be pushed, but for a new local branch. Normally git cherry -v (Alex Nolasko's answer) shows exactly what I want, but this fails for a branch that doesn't yet exist in the remote.

To be more precise, I'd like to see all commits that are not yet in the remote. For example, if I started out on branch "master", made commit 1, then created branch "feature_a" from master and made commit 2 then (still without pushing) created branch "feature_b" from feature_a and made commit 3 I'd like to see commits 1, 2, and 3 listed.

Community
  • 1
  • 1
EM0
  • 5,369
  • 7
  • 51
  • 85

1 Answers1

2

You could try (for a new branch not yet pushed):

git log origin/$(git merge-base master mybranch)..feature_b

The OP EM0 used HEAD for the current branch:

git log $(git merge-base origin/master HEAD)..HEAD

That would list all commits accessible from feature_b but not where feature_b starts (from master, as seem by git merge-base)
That would include commits 2 and 3 (assuming commit 1 from master was pushed, or else the remote repo would be completely empty)

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks, I got it working using a slightly modified version of this: I moved the "origin/" into the merge-base command and used HEAD instead of hardcoding the branch, i.e. `git log $(git merge-base origin/master HEAD)..HEAD` – EM0 Oct 24 '16 at 14:29
  • @EM0 Thank you. I have included your version in the answer for more visibility. – VonC Oct 24 '16 at 15:56