This command is handy for spotting which of your local branches have already been incorporated into the branch you’re on by quickly checking their merge status.
It works by using the --merged flag to tell Git to compare each local branch tip against your current HEAD and print only those branches whose tips are reachable (i.e., already merged). Without any extra flags it defaults to showing local branches, and you’ll see output prefixed by * to mark the active branch. The core parts are:
branch: the subcommand to list branches--merged: filters the list to branches merged into HEAD
You can tweak it with --no-merged to invert the filter and see branches not yet merged, add -r to include remote branches (git branch -r --merged), or combine both local and remote with -a (git branch -a --merged). Other related commands include git branch --no-merged to find unmerged branches or git branch -d <branch> to delete a branch once it’s merged.