I have a number of changes that I committed to my local repository, but have not yet been pushed. Since on a feature is taking longer than expected, I want to swap these changes onto a named branch before I push. How can I do this?
相关问题
- Correct procedure to use pending branch changes in
- Mercurial compared to private branches in SVN
- How to abandon all Mercurial changes that haven
- Windows permissions on a directory: Mercurial - hg
- hg shelve installed but hg: unknown command 'u
相关文章
- Mercurial Commit Charts / Graphs [closed]
- What is the tortoisehg gui equivalent of doing “hg
- How to use Mercurial from Visual Studio 2010?
- Is there a version control system abstraction for
- Tag multiple branches in git?
- Mercurial discard local changes of a file or group
- Mercurial .hgignore Negative Lookahead
- Switch node_modules folder when I change git branc
For those inclined to use GUI
Tortoise Hg
->File
->Settings
then tickrebase
.Restart tortoise UI
Create new branch where you will be moving changes. Click on current branch name -> choose
Open a new named branch
-> choose branch name.public
(e.gdraft
) go to 5. (If changes have already been published and you are not a senior dev you should talk to someone senior (get a scapegoat) as you might screw things up big time, I don't take any responsibility :) ).Go to
View
->Show Console
(or Ctrl + L) then write in consolehg phase -f -d 2
- where 2 is lowest revision you will be moving to new branch.Go to branch and revision (should be topmost revision if you are moving changes to new branch created in step 3.)
Right Mouse
->Update
Go to branch and revsion you will be moving changes from
Right Mouse
->Modify History
->Rebase
Click
Rebase
and pray there are no conflicts, merge if you must.Push changes, at this point all revisions should still be
draft
.Go to topmost revision in branch you were moving changes to
Right Mouse
->Change Phase to
->Public
.Hope this saves you some time.
You can use the MqExtension. Let's say the changesets to move are revisions 1-3:
I prefer the patch solution describe here by Mark Tolonen
What I have:
What I want:
mercurials commands:
Here is the state of my local repository
Now I need to delete the revisions 1 2 and 3 from my default branch. You can do this with strip command from mq's extension.
hg strip
removes the changeset and all its descendants from the repository.Enable the extension by adding following lines to your configuration file (.hgrc or Mercurial.ini):
vim ~/.hgrc
and add :And now strip this repository on revision 1.
and here we are
note: changesets are different but revisions are the same
As suggested by Mark, the MqExtension is one solution for you problem. IMHO a simpler workflow is to use the rebase extension. Suppose you have a history like this:
This means, revision
0
is the base on which you started to work on your feature. Now you want to have revisions1-2
on a named branch, let's saymy-feature
. Update to revision0
and create that branch:The history now looks like this:
Use the
rebase
command to move revisions1-2
onto revision3
:This results in the following graph:
That's it .. as mentioned in the comments to Mark's answer, moving around already pushed changesets generally is a bad idea, unless you work in a small team where you are able to communicate and enforce your history manipulation.