I have two branches Dev and Feature1. I was working on Feature1, creating said feature, and committed it. I then wrote the code for Feature2 but committed it under Feature1 branch instead of a new branch (Feature2). So now i have two features in Feature1 branch as two separate commits, but I only want to include the second feature back into Dev.
What is the mercurial way to do this?
Use hg graft
This command uses Mercurial's merge logic to copy individual changes from other branches without merging branches in the history graph. This is sometimes known as 'backporting' or 'cherry-picking'.
Documentation: https://www.mercurial-scm.org/repo/hg/help/graft
Supposed you have not yet published your commits:
If you want to merge the commit Feature2 independent of commit Feature1, you should move it on its own branch.
If already published:
Use the transplant extension to "duplicate" the Feature2 commit and put it on its own branch. Then backout Feature2 commit on the Feature1 branch. Now you merge Feature2 independent of Feature1 too.
In any case, instead of putting Feature2 on its own branch, you could also put it directly onto your Dev branch if this is your actual intention.
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