Set up Mercurial

Mercurial is one of the DVCS tools that transfers code between your local system and Bitbucket Cloud. Follow the instructions on this page to install Mercurial on your local system. If you write or deploy code to a remote machine, you may also need Mercurial on that machine as well.

If you already have Mercurial installed, make sure you have version 1.7 or later. To find out, open the Command Prompt (search for it if you don't know where it is) and enter hg --version.

$ hg --version

If you receive version information, great! Skip installing and continue to the next step. Otherwise, install Mercurial.

  Install Mercurial for Windows

Do the following to install Mercurial on your Windows machine:

  1. Download a Mercurial installer from the official website. You can choose from a list of different types of Mercurial installers for Windows. If you don't have a preference, install the Mercurial MSI installer for your system.
  2. Open the installer, and follow the prompts to complete the installation.
  3. Open the command prompt. You can find it by searching the the Command Prompt application.
  4. Verify the installation was successful by typing the following at the command line.

    $ hg --version

    Hg is the chemical symbol for Mercury and  hg  is the command for mercurial.

  5. Determine if you already have a  .hgrc  file in your user directory by entering the following at the command line:

    $ ls .hgrc

    If for some reason, you don't have the .hgrc file, you should create one yourself using the touch command:

    $ touch .hgrc
  6. Open the Mercurial configuration file .hgrc  using your favorite editor.
  7. Add a username value to the configuration.

    When you are done, the .hgrc file includes the following lines with your own username and email address:

    [ui]
    # Name data to appear in commits
    username = Emma Paris <eparis@atlassian.com>
  8. Save and close the file.
  Install Mercurial for Mac

If you run into issues while following these instructions, make sure you have root access (sudo) on the system where you want to install Mercurial.

  1. Download the Mercurial installer from the official website.
    The installer is in ZIP file.
  2. Open the ZIP file, and double-click the MPKG file to run the installer.
  3. Follow the prompts to complete the installation.
     
  4. Open a terminal window.
  5. Verify the installation was successful by typing the following at the command line.

    $ hg --version

    Hg is the chemical symbol for Mercury and hg is the command for mercurial. 

  6. Determine if you already have a ~/.hgrc file in your environment by entering the following at the command line:

    $ ls ~/.hgrc

    If for some reason, you don't have the .hgrc file, you should create one yourself using the touch command:

    $ touch ~/.hgrc

    Files that start with a . (period) are hidden files in Mac OSX. By default, the Finder does not show these files. To reveal hidden files, enter the following command into the terminal:

    $ defaults write com.apple.finder AppleShowAllFiles YES

    To hide them files once again, enter the following command:

    $ defaults write com.apple.finder AppleShowAllFiles NO
  7. Open the Mercurial configuration file ~/.hgrc  using your favorite editor.
  8. Add a username value to the configuration.

    When you are done, the ~/.hgrc file includes the following lines with your own username and email address:

    [ui]
    # Name data to appear in commits
    username = Emma Paris <eparis@atlassian.com>

    This is default value Mercurial uses, you can also set this for specific repositories (you'll learn more about this later).

  9. Save and close the .hgrc file.
  Install Mercurial for Linux

Open a terminal window and do the following:

  1. Make sure the universe repository is uncommented in the /etc/apt/sources.list file. 
    To view the file, you can enter cat /etc/apt/sources.list at the command line.  If the  universe  repo is uncommented, the file contains a section similar to the following (example based on Ubuntu 10.04 Lucid Lynx):

    deb http://archive.ubuntu.com/ubuntu/ lucid universe
    deb-src http://archive.ubuntu.com/ubuntu/ lucid universe 
    deb http://archive.ubuntu.com/ubuntu/ lucid-updates universe
    deb-src http://archive.ubuntu.com/ubuntu/ lucid-updates universe 
    deb http://security.ubuntu.com/ubuntu/ lucid-security universe
    deb-src http://security.ubuntu.com/ubuntu/ lucid-security universe 
    

    If the lines are still commented (have a # prefix), then edit the file and uncomment them.

  2. Make sure you have an updated package list by entering the following at the command line:

    $ sudo apt-get update
  3. Enter the following command to install Mercurial:

    $ sudo apt-get install mercurial
  4. Verify the installation was successful by typing which hg at the command line:

    $ which hg
    /usr/bin/hg

    Hg is the chemical symbol for Mercury and hg is the command for Mercurial. 

  5. If you don't already have one, create a file named .hgrc  in your ~ (home) directory.
    This file is the Mercurial global configuration file.
  6. Open the Mercurial configuration file ~/.hgrc  using your favorite editor.
  7. Add a  username  value to the configuration.
    When you are done, the  ~/.hgrc  file includes the following lines with your own username and email address:

    [ui]
    # Name data to appear in commits
    username = Emma Paris <eparis@atlassian.com>
  8. Save and close the file.

Was this helpful?

Thanks for your feedback!

Why was this unhelpful?

Have a question about this article?

See questions about this article

Powered by Confluence and Scroll Viewport