git 想快速刪掉某些 branch

可以運用 Linux command pipeline 的特性

找到一個指令把想要的 branch 列出來,再用 xargs 轉送給 git branch -D 刪除

例如

git branch –list “*test*”  列出名稱包含 test 的 branch (參考資料)

然後我們知道 git branch -D [名稱]  是刪除某個 branch

所以

git branch --list "*test*" | xargs git branch -D

就可以刪除所有名稱包含 test 的 branch

Windows 嗎? 我也不知道,可以參考這篇看看能不能找到 Windows 下等效 xargs 的動作,應該就可以了。

You Might Also Like

Leave a Reply

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料