Defining which branch my next commit is added to

branch, mercurial

Solution

`hg branch X` does nothing except tell Mercurial "the next commit I make should be on branch X." It doesn't actually "create" the branch. A branch doesn't exist until there's at least one commit on it:

sjl at ecgtheow in ~/Desktop/test on default at tip
$ hg branch a
marked working directory as branch a

sjl at ecgtheow in ~/Desktop/test on a at tip
$ hg branch b
marked working directory as branch b

sjl at ecgtheow in ~/Desktop/test on b at tip
$ hg branches
default                        0:aae011bc1b00

sjl at ecgtheow in ~/Desktop/test on b at tip
$ echo foo >> x

sjl at ecgtheow in ~/Desktop/test on b at tip!
$ hg com -m1

sjl at ecgtheow in ~/Desktop/test on b at tip
$ hg branches
b                              1:b66106035d8d
default                        0:aae011bc1b00 (inactive)

sjl at ecgtheow in ~/Desktop/test on b at tip
$ 

So the answer to your question is: "use `hg branch branch-A` to mark the next commit as being on branch-A."

Problem

Let's say I create two banches at the same time: ``` hg branch branch-A hg branch branch-B ``` How do I send my next commit to branch-A instead of branch-B?

Original source