简体   繁体   中英

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.

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.

删除提交或分支不会影响其他分支上的其他提交,即使该提交是在分支之间共享的,或者该分支已合并到其他分支中也是如此。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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