EM0 EM0 - 7 months ago 50
Git Question

How can I see what git commits will be pushed for a NEW git branch?

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.


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

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

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)