Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I add remote repositories in Mercurial?

I am working with Git repositories in the following way:

  • I have the master repository and several remotes on the different production machines.
  • I am pushing the production code to the remotes and restart the services for the changes to take effect.

I am about to switch from Git to Mercurial and I would like to know ahead how I can achieve something like that.

like image 383
topless Avatar asked Feb 10 '11 11:02

topless


People also ask

How do I add a remote repository?

Adding a remote repository To add a new remote, use the git remote add command on the terminal, in the directory your repository is stored at. The git remote add command takes two arguments: A remote name, for example, origin.

How do I find remote repositories?

You can list the remote branches associated with a repository using the git branch -r, the git branch -a command or the git remote show command. To see local branches, use the git branch command. The git branch command lets you see a list of all the branches stored in your local version of a repository.

Can we have more than one remote repositories to track?

You can set multiple remote URLs to a single remote using git remote. If you don't have a remote named 'all' already, create it using git remote add then use git remote set-url –add to add a new URL to the existing remote. You can cross-check added new remotes using git remote -v .


1 Answers

You add entries to the [paths] section of your local clone's .hg/hgrc file. Here's an example of a section that would go in the .hg/hgrc file:

[paths] remote1 = http://path/to/remote1 remote2 = http://path/to/remote2 

You can then use commands like hg push remote1 to send changesets to that repo. If you want that remote repo to update is working directory you'd need to put a changegroup hook in place at that remote location that does an update. That would look something like:

[hooks] changegroup = hg update 2>&1 > /dev/null && path/to/script/restart-server.sh 

Not everyone is a big fan of having remote repos automatically update their working directories on push, and it's certainly not the default.

like image 116
Ry4an Brase Avatar answered Sep 25 '22 09:09

Ry4an Brase