I have a specific commit that was pushed into origin/master but was not ready for prime time. 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?
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:
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:
git checkout master
git revert B # Or whatever the commit hash for B is
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With