[英]The right way to handle adding new mini-features to a feature, which branch has already been merged into master
I don't have too much experience working with git and currently I'm using the local one in Xcode 9
. 我没有太多使用git的经验,目前我在Xcode 9
使用本地的。 I would like to understand the following: Let's say we have two features to implement, called feature1
and feature2
. 我想了解以下内容:假设我们有两个要实现的功能,称为feature1
和feature2
。
Now, to handle the feature1
we create a new branch from the master
, called feature1_branch
. 现在,为了处理feature1
我们从master
创建了一个名为feature1_branch
的新分支。 After successfully implementing that feature, we merge it back into the master
. 成功实现该功能后,我们将其合并回master
。
Then, we create a new branch for the feature2
, called feature2_branch
. 然后,我们为feature2
创建一个名为feature2_branch
的新分支。 Now, we have successfully implemented it, but haven't merged it back into the master
, and we suddenly realise that there is a mini-feature to be added to feature1
. 现在,我们已经成功实现了它,但还没有将它合并回master
,我们突然意识到有一个小功能要添加到feature1
。
So, what is the right policy here: should we merge feature2
into the master
and create a new branch for that mini-feature, called feature1.1_branch
, or should we branch from feature2_branch
and create a new one for the mini-feature? 那么,这里的正确政策是什么:我们应该将feature2
合并到master
并为该迷你功能创建一个名为feature1.1_branch
的新分支,还是应该从feature2_branch
分支并为mini-feature创建一个新分支?
I believe that the second way isn't the right one, because I think intuitively that new branches, created from the existing one, should somehow be related to it, but feature1.1
has nothing to do with feature2
. 我认为第二种方式不是正确的方法,因为我直觉地认为,从现有分支创建的新分支应该以某种方式与它相关,但feature1.1
与feature2
。 But if this case isn't too wrong and we can follow it, how we could merge feature1.1_branch
back? 但是,如果这个案例没有太大错误我们可以遵循它,我们如何将feature1.1_branch
合并回去? I mean, should we first merge it into feature2_branch
or directly into the master
branch? 我的意思是,我们应该首先将它合并到feature2_branch
还是直接合并到master
分支中?
I would appreciate some explanation for this cases from you. 我很感激您对此案件的一些解释。 Thanks in advance. 提前致谢。
Since feature1_branch
has been merged into master–which means it's now a permanent part of your code base, you shouldn't branch feature1.1
off it. 由于feature1_branch
已合并为master - 这意味着它现在已成为代码库的永久部分,因此不应将feature1.1
分支出来。 Just branch off master
like it is a complete new feature that has nothing to do with feature1
( feature1.1
and feature2
then become 2 parallel branches). 刚刚分离出master
就像它是一个与feature1
无关的完整新功能( feature1.1
和feature2
然后成为2个并行分支)。
From what you describe, feature1.1
and feature2
are quite unrelated. 根据您的描述, feature1.1
和feature2
是完全不相关的。 It should be then easy to merge them back. 然后应该很容易将它们合并。 This is similar to having two people working in parallel on different parts of the project: if their work are completely separate, they can just merge them back into master
whenever they are done; 这类似于让两个人在项目的不同部分并行工作:如果他们的工作完全分开,他们只要完成就可以将它们合并回master
; there should be none or very little conflicts. 应该没有或只有很少的冲突。
It is certainly wrong to branch it off feature2_branch
. 将它从feature2_branch
分支出去肯定是错误的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.