Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想创建一个 git 命令,该命令将删除当前分支中包含所有提交的所有分支,例如
$ git branch groups * master $ git cleanup-branches deleted groups # all commits are included in master $ git branch * master
我将如何去创造这个?
您可以git branch -d在这里利用,因为它不会删除任何尚未合并到您当前分支的分支:
git branch -d
git config --global alias.cleanup-branches \ '!git branch | grep -v "\*" | awk "{ print $1 }" | xargs git branch -d'
刚刚在本地尝试过,它工作了,虽然看着它工作有点可怕。