删除 git 中的分支是否会将其从历史记录中删除? [英] Does deleting a branch in git remove it from the history?

查看:84
本文介绍了删除 git 中的分支是否会将其从历史记录中删除?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

来自 svn,刚开始熟悉 git.

Coming from svn, just starting to become familiar with git.

当一个分支在 git 中被删除时,它是否从历史记录中删除?

When a branch is deleted in git, is it removed from the history?

在 svn 中,可以通过还原删除操作(反向合并)轻松恢复分支.与 svn 中的所有删除操作一样,分支从未真正被删除,它只是从当前树中删除.

In svn, you can easily recover a branch by reverting the delete operation (reverse merge). Like all deletes in svn, the branch is never really deleted, it's just removed from the current tree.

如果分支实际上是从 git 中的历史记录中删除的,那么从该分支合并的更改会发生什么?他们被保留了吗?

If the branch is actually deleted from the history in git, what happens to the changes that were merged from that branch? Are they retained?

推荐答案

分支只是指向 git 中提交的指针.在 git 中,每个提交都有一个完整的源代码树,它与 svn 的结构非常不同,svn 中的所有分支和标签(按照惯例)都位于存储库的单独文件夹"中,与特殊的主干"一起.

Branches are just pointers to commits in git. In git each commit has a complete source tree, it is a very different structure from svn where all branches and tags (by convention) live in separate 'folders' of the repository alongside the special 'trunk'.

如果分支在被删除之前被合并到另一个分支,那么当第一个分支被删除时,所有提交仍然可以从另一个分支访问.它们保持原样.

If the branch was merged into another branch before it was deleted then all of the commits will still be reachable from the other branch when the first branch is deleted. They remain exactly as they were.

如果该分支在没有合并到另一个分支的情况下被删除,那么该分支中的提交(直到仍然可以访问的提交的分叉点)将不再可见.

If the branch is deleted without being merged into another branch then the commits in that branch (up until the point where the forked from a commit that is still reachable) will cease to be visible.

提交仍将保留在存储库中,删除后可以立即恢复它们,但最终它们将被垃圾收集.

The commits will still be retained in the repository and it is possible to recover them immediately after the delete, but eventually they will be garbage collected.

这篇关于删除 git 中的分支是否会将其从历史记录中删除?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆