git branch --no-merged
This command is useful for identifying which local branches have not yet been incorporated into your current HEAD by comparing commit histories.
Running git branch --no-merged shows only the names of your local branches that are not merged into the branch you currently have checked out; git branch by itself lists all local branches and the --no-merged flag filters out those that are already merged according to the default reference (HEAD), and you can optionally replace HEAD with a different branch or commit by adding it after the flag.
You can apply variations like git branch --merged to list branches that are fully merged, add -r (git branch -r --no-merged) to check remote-tracking branches, or use -a (git branch -a --no-merged) to include both local and remote branches in the filter.
Examples:
git branch --no-merged maingit branch -r --no-merged origin/develop