823 B
823 B
title, tags, firstSeen, lastUpdated
| title | tags | firstSeen | lastUpdated |
|---|---|---|---|
| Delete merged branches | repository,branch,advanced | 2021-04-08T19:42:01+03:00 | 2021-04-13T21:10:59+03:00 |
Deletes all local merged branches.
- Use
git branch --merged <branch>to list all branches merged into<branch>. - Use the pipe operator (
|) to pipe the output andgrep -v "(^\*|<branch>)"to exclude the current and the target<branch>. - Use the pipe operator (
|) to pipe the output andxargs git branch -dto delete all of the found branches.
git branch --merged <branch> | grep -v "(^\*|<branch>)" | xargs git branch -d
git checkout master
git branch
# master
# patch-1
# patch-2
# Assuming `patch-1` is merged into master
git branch --merged master | grep -v "(^\*|master)" | xargs git branch -d
git branch
# master
# patch-2