Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I "switch" with Mercurial

How do I do what svn switch does, in Mercurial?

That is change my working directory to switch to another branch in the repository?

like image 304
Jonas Meyer Avatar asked Jul 20 '09 21:07

Jonas Meyer


People also ask

How can I change branch 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 to switch branch in intellij?

In the Branches popup, choose New Branch or right-click the current branch in the Branches pane of the Git tool window and choose New Branch from 'branch name'. In the dialog that opens, specify the branch name, and make sure the Checkout branch option is selected if you want to switch to that branch.


2 Answers

hg update -r<REV> 

The update command will switch to a specified revision.

like image 134
Flavius Stef Avatar answered Sep 21 '22 19:09

Flavius Stef


The switch command does two things in Subversion:

  1. Update the working copy to mirror a new URL within the repository. This behaviour is similar to 'svn update', and is the way to move a working copy to a branch or tag within the same repository.

  2. Rewrite working copy URL metadata to reflect a syntactic change only. This is used when repository's root URL changes (such as a scheme or hostname change) but your working copy still reflects the same directory within the same repository.

The hg update foo command matches the former most closely if you switch from, say, /trunk to /branches/foo in Subversion.

If you want to do the latter, then simply edit .hg/hgrc. You'll find a [paths] section that looks like this:

 [paths] default = http://example.net/something 

and you can change this default push/pull URL to something else as you see fit. You can also add other entries to this section if you often need to push/pull from other locations. If you want to pull from one location, but push to another, then add a default-push entry.

like image 29
Martin Geisler Avatar answered Sep 18 '22 19:09

Martin Geisler