Skip to end of metadata
Go to start of metadata

To use Bitbucket, you need to install a DVCS tool on the computer where you write your code. Typically, this computer is a machine physically close to you like your home or work computer. This is your local machine or system. You also might write or deploy code to a remote machine – for example a lab computer or a server in a data center. You may also need a DVCS tool on that machine too. This tutorial refers to the typical case, your local system, but the instructions are the same for both cases.

Bitbucket supports two DVCS tools, Git and Mercurial. These tools run on all modern operating systems.  For Git, Bitbucket supports 1.6.6 or later and Mercurial version 1.7 or later. Mercurial also requires (depends on) the Python programming language. The installation process takes care of making sure you get the correct version of Python.

Since you can use both Git and Mercurial on the same machine, this page shows you how to install both because you need both to complete this tutorial.  If you already have these tools installed, skip the instructions and go to the next step in the tutorial.

Icon

This documentation shows you how to install on Ubuntu Linux. If you want to install on Microsoft Windows or Mac OSX, we have instructions for that too.

Step 1. Install Git

Ubuntu uses the apt package management system, which provides the command line utility apt-get and optional graphical interfaces such as Synaptic and Aptitude.  We'll use apt-get to install packages, but if you're more comfortable with GUIs, those options are available. Open a terminal window on your local system and do the following:

  1. Enter the following command to install Git:

    sudo apt-get install git
  2. Verify the installation was successful by typing which git at the command line.

    $which git
    /opt/local/bin/git
  3. Configure your username using the following command:
    git config --global user.name "FIRST_NAME LAST_NAME"

  4. Configure your email address using the following command:
    git config --global user.email "MY_NAME@example.com"

Step 2. Install Mercurial

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. Edit  the ~/.hgrc file using your favorite editor.
  7. Specify a username value.
    When you are done, the contents of the .hgrc configuration file look something like this:

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

What's next?

 The next step is to Create an Account and a Git Repo 

12 Comments

  1. Anonymous

    Step 6 is ambiguous.  Do you mean we should manually create a directory called .hg in our home directory (~/)? What should the config file name be?

    1. Good catch.  I think I've fixed the confusion.  

    2. Anonymous

      the name is .hgrc !

  2. Anonymous

    For Ubuntu 12.04 the package git-core is obsolete. You should instead install just git. 

    1. Thanks for the catch. I'll fix that.

  3. Anonymous

    What about some instructions for an OS that is far more often being used on live deployment servers in a data center (CentOS).

     

  4. Anonymous

    Any doc for RH-like systems ? Fedora ? CentOS ?

    1. Not any on the horizon.  Were you not able to get started with this?

    2. Anonymous

      To start you off.....

      As a bare minimum for Fedora 18 simply change "sudo apt-get" for "sudo yum" in the three places above, and (as far as I can see) ignore step 2.1

       

  5. Anonymous

    Isn't it easier to use "hg init" ?

  6. On step 2.1 says "(example based on Ubuntu 10.10 Maverick Meerkat)" but the piece of code shown below is from Lucid Lynx. It's a minor issue, I know, but just to avoid confusion to newbies (wink)