简体   繁体   English

Git将修补程序分支合并到功能分支,然后删除修补程序分支?

[英]Git merging hotfix branch into feature branch, then removing hotfix branch?

I'm very new to Git, but am very impressed by the lightweight branching/merging it provides. 我对Git很新,但它给它提供的轻量分支/合并印象非常深刻。

I have three branches in my repository: 我的存储库中有三个分支:

master
1.1.0
1.0.x

I have made a quick fix in the 1.0.x branch, but I'm wondering if I should immediately merge those changes back into 1.1.0 ? 我已经在1.0.x分支中快速修复了,但是我想知道是否应该立即将这些更改合并到1.1.0 Or is it advised to wait until the 1.1.0 branch is ready to be released as a minor version to merge the hotfixes back in? 或者是否建议等到1.1.0分支准备好作为次要版本发布以重新合并修补程序?

And also, in this image: 而且,在这张图片中:

git-scm分支

I'm pretending that iss53 = 1.0.x and master = 1.1.0 for this example. 我假装这个iss53 = 1.0.xmaster = 1.1.0 Once the changes from my 1.0.x hotfix branch have been merged back into the 1.1.0 feature branch, can I continue working on the 1.0.x branch? 一旦从我的1.0.x修补程序分支的更改合并回1.1.0功能分支,我可以继续在1.0.x分支上工作吗?

If I commit a change WHILE working on the 1.0.x branch, after the above merge, will it just create a new horizontal link (to picture it visually) from a hypothetical C7 commit, with a single parent C5 , or will it have two parents, C5 and C6 ? 如果我在1.0.x分支上进行更改,在上面的合并之后,它会从假设的C7提交创建一个新的水平链接(用可视化的方式描绘),单个父C5 ,还是有两个父母, C5C6

This section of the git-book ( Git - Basic Branching and Merging ) also mentions deleting the branch once it is finished, but they unfortunately don't show what the graph would look like afterwards. git-book( Git - Basic Branching and Merging )的这一部分也提到了一旦完成后删除分支,但遗憾的是它们不会显示之后的图形。 Surely the commits are still there - is the label simply removed? 当然,提交仍然存在 - 标签被删除了吗? ( iss53 in the above example.) And once that branch is removed, if you find that Issue 53 wasn't completely fixed, can you continue work from C5 , creating another iss53 branch, or do you have to give it a different name, like iss53_2 ? (在上面的示例中为iss53 。)一旦删除该分支,如果您发现问题53未完全修复, 您可以继续C5 工作 ,创建另一个iss53分支,还是必须给它一个不同的名称,像iss53_2

I'd merge it as soon as you are certain the change is good and needs to go into that branch. 一旦你确定改变是好的并且需要进入那个分支,我就会合并它。 Merging earlier is more likely to succeed without manual effort :) 如果没有人工努力,更早合并更有可能成功:)

The tree will stay exactly the same if you delete the branch, only the label for the branch vanishes. 如果删除分支,树将保持完全相同,只有分支的标签消失。 If you have commits that are no longer reachable from any label then they may eventually be deleted by the garbage collection but it keeps them around for a few weeks, and that's not the case here as all your commits still are reachable in some branch. 如果您的提交不再可以从任何标签访问,那么它们最终可能会被垃圾收集删除,但它会让它们保持几周,而这种情况并非如此,因为所有提交仍然可以在某个分支中访问。

You can easily make the branch again, just do "git checkout -b iss53 xxxxxx" where xxxxx is the commit hex code for the commit you want to base it on. 您可以轻松地再次创建分支,只需执行“git checkout -b iss53 xxxxxx”,其中xxxxx是您希望以其为基础的提交的提交十六进制代码。 git reflog is useful for helping to find the commit you need as it shows all the recent history. git reflog有助于查找所需的提交,因为它显示了所有最近的历史记录。

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

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