Viewing merged and unmerged branches

Sometimes we might forget to delete branches that have already been merged into master. To check which branches have already been merged we use

git branch --merged

Git will return the list of branches that have already been merged into master. Similarly, to check which branches have not been merged we run

git branch --no-merged

We can use these two commands with any branch and Git will show the list of branches that have merged or have not been merged onto our current branch.