Menu

gitpiper

Delete merged branches git Code Snippet in 2025

repositorybranchadvanced

Last Updated: 21 April 2025

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 and grep -v "(^\*|<branch>)" to exclude the current and the target <branch>.
  • Use the pipe operator (|) to pipe the output and xargs git branch -d to 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

git snippet similar to Delete merged branches For You in April 2025

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️

© 2025 GitPiper. All rights reserved

Rackpiper Technology Inc

Company

About UsBlogContact

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️