Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Defining which branch my next commit is added to

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?

like image 261
uzo Avatar asked Sep 21 '09 05:09

uzo


People also ask

What does git branch VV do?

If you want to see what tracking branches you have set up, you can use the -vv option to git branch . This will list out your local branches with more information including what each branch is tracking and if your local branch is ahead, behind or both.

What is the meaning of branch in Git?

A branch represents an independent line of development. Branches serve as an abstraction for the edit/stage/commit process. You can think of them as a way to request a brand new working directory, staging area, and project history.


1 Answers

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

like image 124
Steve Losh Avatar answered Sep 18 '22 03:09

Steve Losh