⬅️ Back to Cleanup Branches Fast ⚡
⬆️ Previous Step: Delete Local Branches Whose Remote is Gone (PowerShell)
Scripts to view and clean up local branches using Bash.
- List local branches without a remote connection.
git branch -vv | grep -E '^\s*\S+\s+[^\[]+$' - Delete local branches without remote tracking.
git branch -vv | grep -E '^\s*\S+\s+[^\[]+$' | awk '{print $1}' | xargs git branch -D - List branches whose remote is gone.
git branch -vv | grep 'gone' - List local branches.
- Delete local branches without remote.
- View branches with deleted remote.
- Delete stale local branches.
⚠️ Deleting branches is irreversible. Double-check before running destructive commands.
Tip
Use 'git branch -vv' to see tracking info for all branches.
Tip
Pipe to 'awk' and 'xargs' for batch deletion.
➡️ See the Next Step: View and Clean Up Local Git Branches (PowerShell)
Author: mike-rambil • Updated: 2024-06-10 • Tags: branches, cleanup, bash