开发者

Hg Merge specific commit from another branch

I have two branches Dev and Feature1. I was working on Feat开发者_如何学JAVAure1, 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


  1. 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.

  2. 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.


include the second feature back into Dev.

Include to Dev and leave in Feature1 - translpant, as mentioned by @oben-sonne Move completely from Feature1 - rebase In case you want rebase into Feature2 you'll have to create this branch (Feature1) before rebase

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜