List all commits in a topic branch

git

Solution

Despite answer is given and accepted I would suggest more automatic way for doing this (but it will only work if you did not merge your `master` to `feature`):

Considering the following history:

--A---B---C---D---E---F---G (master)
       \     /       /
        H---J-------K       (feature)

Basically we want to perform `git log B..feature`.

git log --format='%H' feature..master | tail -1 | \
xargs -I '{}' git log '{}'^..feature

`git log --format='%H' feature..master | tail -1` will find the commit to the `master` that was done right after you created `feature` branch - this is `C`

And ancestor of `C` - `B` will also be the ancestor of the first commit `H` of `feature` branch.

Then `xargs -I '{}' git log '{}'^..feature` (that is turns to `git log B..feature`) just shows the commits that is reachable from `feature` but don't reachable from the `B`.

Problem

I have a feature branch concisely named `feature` that has about 100 commits all related to a feature of sorts. These commits were all merged into the master branch over the time. I want to list all commits that were on the branch so I can re-add the feature to other project. Basically I want to have commit IDs for the green dots on the graph below. How can I do that in Git other then by going to gitk or similar tool and hand-collecting all the relevant commit IDs?

Original source

Related problems