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
.
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.
You can just hg update to the closed branch then do another hg commit and it will automatically reopen.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With