简体   繁体   English

git在3种方式合并后删除分支。 图表看起来像什么?

[英]git deleting branch after 3 way merge. What does it look like as a diagram?

I've been following Scott Chacon's Pro Git Book and I'm reaching the end of chapter 3 in which we have just done a three way merge. 我一直在关注Scott Chacon的Pro Git书,而到第三章的末尾,我们刚刚进行了三步合并。 See the diagram below (my own drawn diagram not a screen grab of the book): 请参见下图(我自己绘制的图,不是本书的屏幕抓图):

在此处输入图片说明

After doing the merge of ' master ' with ' issue53 ', resulting in merge commit c6 , the author says we can delete branch ' issue53 '. 将' master '与' issue53 '合并后,导致合并提交c6 ,作者说我们可以删除分支' issue53 '。

git branch -d issue53

What actually happens to that branch under the hood and what would the resultant diagram look like? 实际情况是该引擎盖下的分支发生了什么,生成的图将是什么样? I ask this because the author does not address the issue. 我问这是因为作者没有解决这个问题。 Would the branch still be there but just not pointed to? 分支会仍然存在但只是没有指向吗? or is there some magic going on that I'm unaware of? 还是发生了一些我不知道的魔术?

What actually happens to that branch under the hood 幕后那个分支实际上发生了什么

That depends on what you mean by the word branch . 那取决于您对“ 分支 ”一词的意思。 See What exactly do we mean by "branch"? 请参阅“分支”到底是什么意思?

and what would the resultant diagram look like? 结果图将是什么样?

Drawing it in ASCII rather than fancy graphics, I get: 用ASCII而不是精美的图形进行绘制,我得到:

C0<-C1<-C2<-C4<---C6   <-- master (HEAD)
          \      /
           C3<-C5

That is, nothing happens to the commits at all. 也就是说, 提交 完全没有任何反应。 The name issue53 , however, which used to point to commit C5 , no longer exists (at all). 但是,曾经指向提交C5名称 issue53根本不存在。

Since every commit in the diagram is still find-able by starting from the name master and working backwards, every commit remains protected from Git's garbage collection process. 由于图中的每个提交仍然可以通过从名称master开始并向后工作来找到,因此每个提交都不受Git的垃圾回收过程的保护。

A branch in git is just a pointer to a commit, and it has a very simple implementation - it is a text file containing the checksum of a commit it is pointing to. git中的分支只是指向提交的指针,它的实现非常简单-它是一个文本文件,其中包含它所指向的提交的校验和。

So in this example, you would have a file .git/refs/heads/issue53 that represents your branch (is your branch). 因此,在此示例中,您将有一个文件.git/refs/heads/issue53代表您的分支(即您的分支)。

And when you delete a branch in git, you delete that text file (pointer) representing that branch. 并且当您在git中删除分支时,将删除代表该分支的文本文件(指针)。 In this case, .git/refs/heads/issu53 在这种情况下, .git/refs/heads/issu53

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

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