简体   繁体   English

当一个(未合并的)Git分支不再有效时删除它?

[英]Delete an (unmerged) Git branch when it is no longer active?

I have some maintenance branches in Git that were used to create emergency releases (ie to fix a critical bug in production). 我在Git中有一些用于创建紧急版本的维护分支(即修复生产中的关键错误)。 These branches are usually not merged back to master, because they either contain one-off fixes or have changes that were cherry-picked from master. 这些分支通常不会合并回master,因为它们要么包含一次性修复,要么具有从master中挑选出来的更改。

As a matter of practice, should these maintenance branches be deleted in Git if they are tagged (at build time)? 作为一种惯例,如果这些维护分支被标记(在构建时),是否应该在Git中删除这些分支? Will deleting them cause those commits to be lost? 删除它们会导致这些提交丢失吗?

No commit will be lost if it's reachable from a tag or a branch head. 如果可以从标签或分支头部访问,则不会丢失提交。

If you tagged a branch, and then made another commit, and then deleted the branch, that last commit would be liable to garbage collection (at some point in the future - you can still recover it using reflog if you don't wait too long). 如果你标记了一个分支,然后进行了另一次提交,然后删除了分支,那最后一次提交就会被垃圾回收(在将来的某个时候 - 如果你不等待太久,你仍然可以使用reflog恢复它)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM