2023-03-20 13:39:43 +00:00
|
|
|
---
|
|
|
|
tags: [git]
|
|
|
|
---
|
|
|
|
|
|
|
|
# Identify merged branches
|
|
|
|
|
|
|
|
```sh
|
|
|
|
# View merged
|
|
|
|
git branch --merged
|
|
|
|
|
|
|
|
# View merged remote
|
|
|
|
git branch -r --merged
|
|
|
|
|
|
|
|
# View unmerged
|
|
|
|
git branch --no-merged
|
|
|
|
|
|
|
|
# View unmerged remote
|
|
|
|
|
|
|
|
git branch -r --no-merged
|
|
|
|
```
|
|
|
|
|
2024-02-02 15:58:13 +00:00
|
|
|
The above cases run the merge check from the point of view of HEAD as this is
|
|
|
|
the default.
|
2023-03-20 13:39:43 +00:00
|
|
|
|
|
|
|
But we can also run it from any branch.
|
|
|
|
|
|
|
|
```
|
|
|
|
git branch --merged non_head_branch
|
|
|
|
```
|
|
|
|
|
|
|
|
## Demonstration
|
|
|
|
|
|
|
|
We have the following branches
|
|
|
|
|
|
|
|
```
|
|
|
|
git branch
|
|
|
|
|
|
|
|
* main
|
|
|
|
key_feature
|
|
|
|
another_feature
|
|
|
|
```
|
|
|
|
|
|
|
|
The branches other than `main`, have not been merged:
|
|
|
|
|
|
|
|
```
|
|
|
|
git branch --merged
|
|
|
|
|
|
|
|
* main
|
|
|
|
```
|
|
|
|
|
|
|
|
Just to confirm:
|
|
|
|
|
|
|
|
```
|
|
|
|
git branch --no-merged
|
|
|
|
|
|
|
|
key_feature
|
|
|
|
another_feature
|
|
|
|
```
|