Reputation: 1547
My repo is currently as follows:
O 7: default
|
O 6: default
|
| O 5: default
| |
| O 4: default
| |
| O 3: default
| /
O 2: default
|
O 1: default
I would like to move 6 and 7 to a new branch, how can I do it?
Upvotes: 0
Views: 524
Reputation: 7755
Depends how you define the term "branch". If you're talking about named branches then Steve Kaye's answer is fine.
If you're talking about a branch like 5 & 6 are on a branch in your diagram, then you don't need to do anything. 6 & 7 are already on their own branch. You can leave them alone, and move back to revision 2 to continue work there.
hg update 2
<continue work>
hg commit -m "New Stuff"
That will leave you with a graph like this:
o 8: default
|
| O 7: default
| |
| O 6: default
| |
| | O 5: default
| | |
| | O 4: default
| | |
| | O 3: default
\ | /
O 2: default
|
O 1: default
If you want to assign a name to each of those tips, take a look at bookmarks.
hg bookmark -r 8 stable
hg bookmark -r 7 experimental-stuff
hg bookmark -r 5 some-feature
... and then you can change between them by name.
Upvotes: 2
Reputation: 6262
You can use the rebase extension for this. It needs to be enabled but that link has the information on how to do it.
The commands would be:
hg update 2
hg branch newbranch
hg commit -m "Creating new branch"
hg rebase -s 6 -d 8
This creates the new branch, commits it (which would create revision 8 in your example) and then moves revision 6 and its descendants onto the new branch. Obviously, you'd need to look up the actual revision numbers for your repository.
You could also do it with the mq extension but I think that rebase is easier to use in this instance.
Upvotes: 2