[英]Move specific git commit from master to branch
I have a specific commit that was pushed into origin/master but was not ready for prime time. 我有一个特定的提交被推入origin / master但尚未准备好黄金时间。 It should have gone into a separate existing feature branch that will eventually be merged into master.
它应该进入一个单独的现有功能分支,最终将合并为主分支。 How can I pluck the commit out of master and move it into the feature branch?
如何从master中取出提交并将其移入功能分支?
Here's what I have in the remote branches: 这是我在远程分支中的内容:
a B c d
master - o --- o --- o --- o -->
\
newbranch - - o --- o -->
p q
The errant commit B
needs to be moved to newbranch
: 需要将错误提交
B
移动到newbranch
:
a c d
master - o --- o --- o -->
\
newbranch - - o --- o --- o -->
B p q
Is this possible to achieve? 这有可能实现吗?
If you have already pushed the commit, then any attempt to rewrite the existing graph will require a force-push, which will make other members of your team sad. 如果您已经推送了提交,那么任何重写现有图形的尝试都需要强制推送,这将使您团队中的其他成员感到悲伤。
Therefore, the best solution is to simply commit a revert to master
: 因此,最好的解决方案是简单地提交一个revert to
master
:
git checkout master
git revert B # Or whatever the commit hash for B is
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.