简体   繁体   English

GIT-合并后分支未关闭

[英]GIT - branches not closing after merge

we are pretty unexperienced in using GIT. 我们在使用GIT方面经验不足。 Actually we like the idea of branches ;-) But somehow all merges from one user just don't close the branch... 实际上,我们喜欢分支的概念;-)但是以某种方式,所有来自一个用户的合并都不会关闭分支...

You can look at the image here: http://i54.tinypic.com/297i14.png 您可以在此处查看图像: http : //i54.tinypic.com/297i14.png

There is a grey and a blue line which just got straight forward... even after the merge... So what is he doing wrong? 一条灰色和一条蓝色的线一直直达……甚至在合并之后……那么他在做什么错呢? Any clues? 有什么线索吗? I don't want imagin what happens if he creates some more branches and all of them persist in the history view even after a merge... 我不想想象如果他创建了更多分支并且即使合并后所有分支仍保留在历史视图中会发生什么...

Thank you very much! 非常感谢你!

When you do a merge, the new commit only moves forward your current branch. 进行合并时,新提交只会向前移动当前分支。 The branch name that pointed to the other branch is left where it was. 指向另一个分支的分支名称保留在原位置。 In other words, if you have this situation: 换句话说,如果您有这种情况:

A---B---C blue
 \
  D---E---F grey

... and do: ...并执行:

git checkout blue
git merge grey

You'll end up with: 您最终将得到:

A---B---C---G blue
 \         /
  D---E---F grey

If you want to remove the grey branch you can then do git branch -d grey . 如果要删除grey分支,则可以执行git branch -d grey This won't affect the commit graph, just remove the branch - they're like labels that get moved around the commit graph. 这不会影响提交图,只需删除分支-它们就像在提交图周围移动的标签一样。

However, if you carry on and create more commits on the grey and blue branches, those lines will continue: 但是,如果继续进行并在greyblue分支上创建更多提交,则这些行将继续:

A---B---C---G---H---I blue
 \         /
  D---E---F---J---K---L grey

In the image you link to, I assume that either there are further commits further above the section you've shown, or the tool you're using is just presenting the commit graph strangely. 在您链接到的图像中,我假设要么您所显示的部分上方还有其他提交,要么您使用的工具只是奇怪地呈现了提交图。

I am not certain what you mean by closing the branch, but I'll make a guess :) 我不确定关闭分支意味着什么,但我会猜测:)

It is still possible to use a branch even after a merge has been done. 即使完成合并后,仍然可以使用分支。 I guess this is per design and how it should be. 我想这是每个设计以及应该如何设计的。 For instance you might want to continue working with the branch even after a merge has been done, say in order to continue focusing on development in that branch. 例如,即使合并完成后,您可能仍想继续与分支合作,例如为了继续专注于该分支的开发。 That is why it still shows up in the image you referred to. 这就是为什么它仍显示在您引用的图像中的原因。

If you don't want to do that, it is possible to delete the branch after merging, which closes it definitively by issuing the command git branch -d <branch> while being in another branch, like master. 如果您不想这样做,可以在合并后删除分支,这可以通过在另一个分支(例如master)中发出命令git branch -d <branch>来最终关闭它。 (This will only delete the branch if its latest commit has been merged with the branch you have active, so there is no risk of losing data.) (这仅会在分支的最新提交已与您活动的分支合并后删除该分支,因此不会丢失数据。)

Currently git requires a two step process for the merging and closing of a 'task' branch where the merge nominally indicates closure of the task and that the branch is no longer required. 当前,git需要两个步骤来合并和关闭“任务”分支,其中合并名义上表示任务已关闭,并且不再需要该分支。

It maybe that it would be a useful option for some to be able to delete a branch's refs/heads entry so closing everything in one step [make a proposal to the git list?]. 对于某些人来说,删除分支的refs / heads条目将是一个有用的选择,因此一步关闭所有内容[向git列表提出建议?]。 However I'm sure that many workflows have instances where they want the ability to go back and tidy up some minor issue, which an early deletion would make awkward. 但是,我敢肯定,许多工作流程中都有一些实例,他们希望它们能够返回并整理一些小问题,而这些问题如果过早删除会很尴尬。 (though it would be in the reflog for a while) (尽管它会在reflog中保留一段时间)

Give the user the task of creating an alias or script to combine the two actions. 向用户提供创建别名或脚本以结合这两种操作的任务。 It will help the education all round ;-) 它将帮助全面的教育;-)

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

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