问题描述
从svn开始,刚开始熟悉git。
当一个分支在git中被删除时,它是否会从历史中删除?
在svn中,您可以通过恢复删除操作(反向合并)轻松恢复分支。和svn中的所有删除一样,该分支从不真正删除,它只是从当前树中删除。
如果该分支实际上从git中的历史中删除,会发生什么到从该分支合并的更改?它们是否保留?
分支只是指向git提交的指针。在git中,每个提交都有一个完整的源代码树,它与svn非常不同,它的所有分支和标签(按照惯例)与特殊的trunk一起存放在资源库的单独文件夹中。
如果分支在被删除之前被合并到另一个分支中,那么当第一个分支被删除时,所有提交仍然可以从另一个分支到达。它们保持原样。
如果分支被删除而未被合并到另一个分支中,那么该分支中的提交(直到从提交分支仍然可以访问)。
提交仍将保留在存储库中,并且可以在删除后立即恢复它们,但最终它们将被垃圾收集。
Coming from svn, just starting to become familiar with git.
When a branch is deleted in git, is it removed from the history?
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.
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?
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中删除分支是否将其从历史记录中删除?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!