How to add symbolic name for Mercurial repository

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

default =

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

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:

default =
bkp =

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

How to find the repositories which contain a Ubuntu package

If you add a lot of PPA repositories, you might run into a situation where you want to figure out the repository which contains a given package. The madison option of the apt-cache command can be used to list the repositories that contain a given package.

For example, to find the repositories of a package named foo:

$ apt-cache madison foo

Tried with: Ubuntu 12.04 LTS

How to remove APT repository in Ubuntu

You can install packages from third party sources by adding their APT repositories to Ubuntu. If you do not want to keep them later, these packages can be removed and the repositories can be removed too.

If you remember the name of the repository, say ppa:joe/foobar, use this command:

$ sudo add-apt-repository --remove ppa:joe/foobar

The short -r can be used instead of --remove.

If you do not recall the name of the repository, go to /etc/apt/sources.list.d/ directory and remove the filename that matches the repository you want to remove. You will need to use sudo for this.

After removing the repository in either of the above ways, remember to update:

$ sudo apt-get update

Tried with: Ubuntu 14.04

How to add a repository to Ubuntu

Not all packages for Ubuntu is available through its official repositories. Many interesting applications are available from other repositories. Some applications are available from their developers directly in the form of Personal Package Archives (PPA), which are also shared as repositories. These packages can be installed and updated using the apt tools, if their repository is added to Ubuntu.

To add any repository, for example a PPA repository named ppa:joe/foobar, to Ubuntu:

$ sudo add-apt-repository ppa:joe/foobar
$ sudo apt-get update

Always remember to update after adding a repository. Else the package listing from the newly added repository will not be available and so packages from it cannot be found or installed.

Tried with: Ubuntu 12.04.2 LTS