Dave Kennedy Dave Kennedy - 1 year ago 59
Git Question

How can I tell which commits are included in merge?

I merged branch develop into branch my-feature with the following command:

$ git merge --no-ff develop

I expected that afterwards my-feature branch would be ahead of origin/my-feature by two commits: the merge commit and the other that I wanted to bring in. However,
git status
reports that it's ahead by three commits:

$ git status
On branch my-feature
Your branch is ahead of 'origin/my-feature' by 3 commits.
(use "git push" to publish your local commits)
nothing to commit, working directory clean

I'd like to figure out which commits were included in the merge without combing through the logs. Is there a command to list them or just list the commits that are "ahead"? I tried doing a hard reset and using
git merge --log
, thinking it would list them in the log message, but it only showed one commit.

Answer Source

You can use

git log origin/my-feature..my-feature

to see the commits that are in your branch, but have not yet been pushed (the ahead commits).

Since you are already on my-feature though, you can shorten it to:

git log origin/my-feature..
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download