git cleanup old branches
I'd like to create a git command that will delete any branches that have all commits included in the current branch eg
$ git branch
groups
* master
$ git cleanup-branches
deleted groups # all commits are included in master
$ git branch
* master
How would I go about creating this?
You can leverage git branch -d
here, as it won't delete any branch not yet merged into your current branch:
git config --global alias.cleanup-branches
'!git branch | grep -v "*" | awk "{ print $1 }" | xargs git branch -d'
Just tried this locally and it worked, although it is a little terrifying to watch it work.
链接地址: http://www.djcxy.com/p/26058.html上一篇: 我怎么能在git中知道一个分支是否已经重新绑定到master?
下一篇: 混帐清理旧分支