Starting a mercurial (hg) remote repository

I always forget and have to search for the correct order of things here…

There are some VCS — as in Version Control System — (and DVCS, where the “D” stands for Distributed) where you can create a copy of the repository on your own system and then somewhat easily move it to the server or copy it there using the VCS software itself.

Mercurial seems to require that the thing be done in two stages:

  1. Create the repository on the central (reference) server
  2. Clone the repository on each workstation

So, here are the commands that should be run to accomplish that:

At the reference server

hg init <repository_name>

At the workstation

hg clone ssh://user@server//path/to/repository/<repository_name> <local_name>

Yes, it is that simple…  But since I work for a long time on projects, I always forget to double the slash after the server name while cloning and that I need to create the repository on the server “first”, to later start working with it locally.

I could probably do the opposite and revert the clone order, but then I am not sure if “push” and “pull” would be switched or if something else would be required to make them work.

About these ads

One response to “Starting a mercurial (hg) remote repository

  1. When you clone from a remote repository, all it is doing is keeping a little note of where the repository was cloned from as your default push/pull destination. You can easily change this – it’s stored in the RepoRoot/.hg/hgrc file.

    So you can start with hg init on the workstation, and when you’re ready to send it somewhere, do hg init at the server, then edit your local repository’s hgrc file as such:

    [paths]
    default = ssh://user@server//path/to/repository/

    Then you can push. If you goof and forget the double slashes, you can fix it, and then push.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s