[英]GIT: How to delete all Hotfix and Feature branches, and keep Development, Releases and Master - automatically?
As a way to organize my repositories, I would like to know how to run either a command or script to delete all Hotfix and Feature branches only. 作为组织我的存储库的一种方法,我想知道如何运行命令或脚本来仅删除所有Hotfix和Feature分支。 I intend to do this once they are not useful anymore. 一旦它们不再有用,我打算这样做。 These branches will sometimes be used on both local and remote. 这些分支有时会在本地和远程使用。
For the safety of the branches in your repo, please read the entire answer. 为了您回购中分支机构的安全,请阅读完整的答案。
I'm going to assume that all your feature or hotfix branches have feature or hotfix in the name. 我将假设您的所有功能或修补程序分支在名称中都有功能或修补程序。 The command to delete all of them would be the following 删除所有这些命令的命令如下
git branch -D `git branch | grep -E '(hotfix|feature)'`
HOWEVER, before you run that, run 但是,在运行之前,请运行
git branch | grep -E '(hotfix|feature)'
This command will tell you exactly which branches are going to be deleted. 此命令将准确地告诉您要删除哪些分支。 Only after you are satisfied with the output of this, should you run the first command above. 只有在对此输出感到满意后,才应运行上面的第一个命令。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.