less than 1 minute read

To see a list of which commits are on one branch but not another, use git log:

git log --no-merges oldbranch ^newbranch

You can list multiple branches to include and exclude, e.g.:

git log  --no-merges oldbranch1 oldbranch2 ^newbranch1 ^newbranch2

The --no-merges flag exclude commits that are merges.

[You can show] commits and commit contents from other-branch that are not in your current branch:

git show @..other-branch

Additionally you can apply the commits from other-branch directly to your current branch:

git cherry-pick @..other-branch

To show the commits in oldbranch but not in newbranch:

git log newbranch..oldbranch

To show the diff by these commits (note there are three dots):

git diff newbranch...oldbranch

[To] list all branches [that] contain the commits from “branch-to-delete”:

git branch --contains branch-to-delete

Via Stack Overflow.

Tags: ,

Categories:

Updated:

Leave a comment