πŸš€ Clean Up Your Local Git Branches! 🧹

Temuri Takalandze - Feb 21 - - Dev Community

Image description

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! βœ…

. . . . . . . . . . . . . . . . . . . . . . . . . .