Over time, local branches pile up, especially after merging or deleting them remotely. To remove local branches that no longer have a remote counterpart, follow these simple steps:
1️⃣ List branches that are gone from the remote:
๐ git branch -vv | awk '/: gone]/{print $1}'
3️⃣ Delete them:
๐ git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -d
⚠️ If Git complains that a branch is not fully merged, use -D instead of -d, but be careful! ๐จ
Keep your workspace clean & organized! ✅
0 Comments