Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to add symbolic name for Mercurial repository

📅 2014-Feb-28 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ mercurial, repository, symbolic name ⬩ 📚 Archive

When you clone a repository in Mercurial, it creates a file .hg/hgrc in the new clone repository. Typically, this has the following lines:

[paths]
default = https://joe@someserver.org/joe/foobar

That is, it has the login, the source location (directory or internet domain), the repository owner and finally the repository name. This assigns a symbolic name of default to this repository. After this any push or pull command is done with this repository.

If you created a new Mercurial repository and want to push it to another existing repository, then the command is:

$ hg push https://joe@someserver.org/joe/foobar

If you want to push or pull without having to specify the repository, then just create a .hg/hgrc file and add the above lines to it.

If you want to add other repositories to push-pull from, add them on separate lines with a different symbolic name, not default:

[paths]
default = https://joe@someserver.org/joe/foobar
bkp = https://joe@bkpserver.org/joe/foobar

You can push-pull from that repository using the symbolic name you have given it:

$ hg pull bkp

Tried with: Mercurial 2.0.2 and Ubuntu 12.04 LTS


© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘 @codeyarns@hachyderm.io📧