[英]Do I have to do cherry-pick?
Developers suppose to create a feature branch from master and then start coding but instead they have created a feature branch from develop branch and then merged into a develop branch.开发人员假设从 master 创建一个 feature 分支,然后开始编码,但是他们已经从 develop 分支创建了一个 feature 分支,然后合并到一个 develop 分支。 (not all the features from develop branch will be on master branch)
(并非来自 develop 分支的所有功能都在 master 分支上)
When I try to create a PR to merge his feature branch (not develop) to a release branch (release branch are created from a master branch) - it is showing commits on PR that he did not commit and the commits are showing from develop branch that does not exist on master branch.当我尝试创建一个 PR 以将他的功能分支(不是开发)合并到一个发布分支(发布分支是从主分支创建的)时 - 它在 PR 上显示他没有提交的提交,而提交是从开发分支显示的在 master 分支上不存在。 why did that happen?
为什么会这样?
Developer have only committed Task-6 Suspend Post
on to Task-6-Suspend-Post
branch.开发人员仅将
Task-6 Suspend Post
提交到Task-6-Suspend-Post
分支。
Example:例子:
https://github.com/superc0der/test/compare/RELEASE/1.5.0...Task-6-Suspend-Post?expand=1 https://github.com/superc0der/test/compare/RELEASE/1.5.0...Task-6-Suspend-Post?expand=1
Only Task-6 Suspend Post
should be merged on release branch.只有
Task-6 Suspend Post
应该在发布分支上合并。 ( https://github.com/superc0der/test/commit/62f68ec3d951bca5b848932df01ea8a29f0f562f ) ( https://github.com/superc0der/test/commit/62f68ec3d951bca5b848932df01ea8a29f0f562f )
Do I need to do cherry-pick or what is other solution to solve this?我需要做樱桃挑选还是其他解决方案来解决这个问题? Having same problem with a few Features branches.
一些功能分支有同样的问题。
A merging operation joins two (or more) branches together into a single commit (the merge commit).合并操作将两个(或更多)分支合并为一个提交(合并提交)。 You have the below situation:
您有以下情况:
A - B (master)
\
C - D (develop)
\
E (Task-6-Suspend-Post)
Since Task-6-Suspend-Post
branch is created from develop
it contains commit C
and D
in its history.由于
Task-6-Suspend-Post
分支是从develop
创建的,它在其历史记录中包含提交C
和D
When performing merge of Task-6-Suspend-Post
into master
the following history will look like below:将
Task-6-Suspend-Post
合并到master
,以下历史记录将如下所示:
A - B --------- G
\ /
C - D /
\ /
E
In other words the PR is a requets to create a merge commit for the latest on master ( B
) and the latest on Task-6-Suspend-Post
( E
).换句话说,PR 是为 master (
B
) 上的最新和Task-6-Suspend-Post
( E
) 上的最新创建合并提交的请求。 This will make commits C
and D
available through the history of master and thus included in the pull request.这将使提交
C
和D
通过 master 的历史记录可用,从而包含在拉取请求中。
Making a rebase of the Task-6-Suspend-Post
will solve your problem.对
Task-6-Suspend-Post
进行rebase将解决您的问题。
git rebase master Task-6-Suspend-Post
The above command will create a new commit E'
with the same content as E
but with the head of master ( B
) as parent.上述命令将创建一个新的提交
E'
具有相同内容作为E
但与主站(的头B
)作为父节点。 The branch pointer Task-6-Suspend-Post
will be attached to the new E'
commit.分支指针
Task-6-Suspend-Post
将附加到新的E'
提交。
E' (Task-6-Suspend-Post)
/
A - B (master)
\
C - D (develop)
By force pushing the new Task-6-Suspend-Post
and making anew pull request only one commit should be part of the PR.通过强制推送新的
Task-6-Suspend-Post
并发出一个新的拉取请求,只有一个提交应该是 PR 的一部分。
git push origin -f
If it is a single commit, cherry pick is viable.如果是单次提交,cherry pick 是可行的。 However, rebase does a lot of the work for you to move the branch.
但是,rebase 为您移动分支做了很多工作。 With multiple commits, rebase also requires less work on your part.
通过多次提交,rebase 还需要您做更少的工作。
With a develop branch with the current features and bug fixes, a common workflow is to create new feature branches from the develop branch rather than from master.对于具有当前功能和错误修复的开发分支,常见的工作流程是从开发分支而不是从主分支创建新的功能分支。 Then the feature branch is merged into develop.
然后将功能分支合并到开发中。 Then a release branch can also be created from develop when you are ready and when the final release happens merge into master and tag the release.
然后,当您准备好并在最终发布时合并到 master 并标记发布时,也可以从 develop 创建一个发布分支。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.