[英]Can I safely remove my Git topic branch that has been merged into master?
如果我创建并推送了很久以前已合并到master的主题分支,是否可以安全地运行git push origin :foobranch
而不必担心它会以某种方式删除合并到master或其他分支的数据?
As long as there are no outstanding commits, its safe. 只要没有未完成的提交,它都是安全的。 If you want to be sure
如果您想确定
git checkout master
git merge foobranch
This should result in a fast-forward merge (that does not affect the history). 这将导致快速合并(不影响历史记录)。 If not, maybe there were unmerged commits.
如果没有,也许有未合并的提交。 However, now you are completely safe
但是,现在您完全安全了
git branch -d foobranch
git push origin :foobranch
Yes, you can safely delete a branch that has been merged into another branch. 是的,您可以安全地删除已合并到另一个分支的分支。 Branches are like movable pointers into the commit graph, and if you delete a branch, it's just removing that pointer.
分支就像提交图中的可移动指针,如果删除分支,则只是删除该指针。 The commit graph remains, and in your case the
master
branch will still contain the history of the branch you've removed. 提交图仍然存在,在您的情况下,
master
分支仍将包含已删除分支的历史记录。
It is perfectly safe. 这是绝对安全的。
Any commit is linked to a tree (ie, your project files), and potentially, several commits point to the same tree. 任何提交都链接到一棵树(即,您的项目文件),并且可能有多个提交指向同一棵树。 It is only when no commit links to a tree anymore that it may be garbage collected.
只有当不再有提交链接链接到树时,它才可能被垃圾回收。
If you still need to recollect it somehow and don't even have a local ref to the commit, there is the reflog, which is cleaned up only after 90 days (I think ) by default. 如果您仍然需要以某种方式重新收集它,甚至没有提交的本地引用,则有一个reflog,默认情况下,该日志仅在90天(我认为 )之后才被清除。
删除提交或分支不会影响其他分支上的其他提交,即使该提交是在分支之间共享的,或者该分支已合并到其他分支中也是如此。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.