How to list all unmerged changes in Git?

Viewed 50800

Creating a branch for various topics, and not regularly deleting them when I don't need them any more, I have now ended up with about 50 branches.

I tried deleting branches but some of them have unmerged changes.

What I want is the ability to see exactly what changes are there in any branch on my repo that are not in master. Is there a way to do that?

5 Answers

This question is already well answered, but there is one more answer I think is worth documenting:

List all commits on any branch not already merged with master:

git log --all --not master

or, equivalently:

git log --all ^master

The --all picks up all branches, so you don't have to list them, then --not master or ^master removes master from the selection.

For the PowerShell folk a little combination of what has been said above. If needed, replace master with main. Test by pasting into your shell.

$notMergedList = (git branch --no-merged master) -replace " ", ""
ForEach($branchItem in $notMergedList) {
  write-host "~~> branch: $branchItem" -Foregroundcolor DarkCyan
  git cherry -v master $branchItem }
Related