> For the complete documentation index, see [llms.txt](https://yu-sun.gitbook.io/essential-git-for-scientists/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://yu-sun.gitbook.io/essential-git-for-scientists/cookbook/identify-merged-branches.md).

# Identify merged branches

### Rationale

* You might want to delete a branch (e.g. a feature branch).
* Before you do that, you might want to check whether that branch is fully merged.
* In others, you should know which branches are fully included in the current branch.

### Command

* `git branch --merged` show the branches merged with the current branch.
* `git branch --no-merged` similar, but show the *NOT* merged
* Both can be used with the `-r` to include the remote tracking branch.

### Notes

* From officials, merged branches means

  > Branches whose tips are reachable from the specified commit (`HEAD` if not specified).
* If you traverse backwards from the commit specified (default: `HEAD`), do you see the tip (end) of those commits?
  * If so, then it's merged.
* You can provide the commit to travers from.
  * `git branch --merged <name>`
  * `git branch --merged origin/<name>`
