简体   繁体   English

GIT:如何删除所有修补程序和功能分支,并自动保留开发,发布和主控?

[英]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.

相关问题 如何成功保持主分支和开发分支同步? GIT - How to successfully keep master and development branches in sync? GIT 具有多个分支的maven项目修补程序版本的Git合并策略 - Git merge strategy for maven project hotfix releases with multiple branches 如何删除除master之外的所有Git远程分支? - How to delete all Git remote branches except master? Git:如何删除所有本地分支(合并与否),除了master和develop - Git : How to delete all local branches (merged or not), except master and develop 是否有将git与Feature Branch工作流程一起使用的修补程序版本的约定? - Is there a convention for hotfix releases using git with the Feature Branch workflow? git:从所有历史记录中删除文件和目录,但保留所有分支(不仅是master分支) - git: Delete files and directories from all history but keep all branches (not just the master branch) Git工作流,用于不断变化的master和发布分支 - Git workflow for constantly diverged master and releases branches GIT 基础 - Master 和 Feature 分支 - GIT Basics - Master and Feature Branches 如何删除所有本地git分支,但使用一个命令行保持master状态? - How to remove all local git branches but keep master with one command line? 如何在实时更新中使用git功能分支并合并回master? - How to use git feature branches with live updates and merge back to master?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM