Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Switching between Mercurial branches

If I look at Mercurial's site, it seems to tell me to use update -C to switch between branches. Another Stack Overflow answer says to use checkout instead.

What are the differences? It seems to me that checkout updates the files in the working directory to the branch too, like update -C.

like image 430
wrongusername Avatar asked Oct 31 '10 03:10

wrongusername


People also ask

How do I change branches in mercurial?

From the main menu, select Hg | Mercurial | Update to. In the Switch Working Directory dialog that opens, specify the target working directory: To switch to another line of development, choose Branch and select the desired branch from the list.

How do I open a closed branch in mercurial?

You can just hg update to the closed branch then do another hg commit and it will automatically reopen.

What is a branch in Mercurial?

Branches occur if lines of development diverge. The term "branch" may thus refer to a "diverged line of development". For Mercurial, a "line of development" is a linear sequence of consecutive changesets. Combining a line of development into an existing one is called merging. Creating a branch.

How do I merge Mercurials?

To merge two branches, you pull their heads into the same repository, update to one of them and merge the other, and then commit the result once you're happy with the merge.


1 Answers

hg checkout and hg update are aliases for each other, so can be used interchangeably. From the help for hg update:

hg update [-c] [-C] [-d DATE] [[-r] REV]  aliases: up, checkout, co  update working directory (or switch revisions) 

-C or --clean option is used to throw away uncommitted changes when switching.

like image 189
Niall C. Avatar answered Oct 15 '22 00:10

Niall C.