[英]Merging a commit off of one branch, to be based off of another branch
I have a master
branch and a staging
branch for my project.我的项目有一个
master
分支和一个staging
分支。 I just pushed up a separate develop
branch that is off of master
, but I need it to be off of staging
.我刚刚推出了一个独立的
develop
分支,它脱离了master
,但我需要它脱离staging
。
Is there anyway to take the develop
branch which is 1 commit ahead of master and have it so it is off of my staging branch
?无论如何,是否可以采用比 master 早 1 次提交的
develop
分支,并让它脱离我的暂存branch
? So ultimately it would only be one commit ahead of staging
?所以最终它只会在
staging
之前提交一次?
I might be tempted to suggest doing a simple rebase of develop
on staging
:我可能会建议在
staging
上做一个简单的develop
变基:
git checkout develop
git rebase staging
This would replay all the commits in develop
which occurred after the point where staging
diverged from master
directly on top of the staging
branch.这将重播所有在提交
develop
这点在哪里发生后staging
从分歧master
直接在上面staging
分支。 But this might also play certain master
commits on top of staging
, which does not sound like what you want.但这也可能会在
staging
之上播放某些master
提交,这听起来不像您想要的。
So if all you want to do is to play that single commit on top of staging
and have it be the develop
branch, you can try this:因此,如果您只想在
staging
之上播放单个提交并将其作为develop
分支,则可以尝试以下操作:
git checkout staging
git checkout -b new_develop
git cherry-pick <SHA-1 of single commit>
Then delete the old develop
branch, and rename new_develop
to develop
:然后删除旧的
develop
分支,并将new_develop
重命名为develop
:
git branch -d develop
git branch -m new_develop develop
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.