Set up Git and Mercurial

Redirection notice

This page will redirect to Set up version control .

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. Bitbucket supports Git 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.

Linux or Mac User?

Mac users see this page.
Linux users see this page.

Step 1. Install Git for Windows

Here's how to install Git on your Windows machine:

  1. Download the Git for Windows installer package.
    You can either Run the installer directly from your browser's File Download dialog or you can Save the file to a folder on your computer.
  2. When you've successfully started the installer, you should see the Git Setup wizard screen. Follow the Next and Finish prompts to complete the installation.

    The system opens the release notes. You might want to skim them.
  3. Open Git Bash.vbs from the Git folder of the Programs directory to open a command window.

    Using the Git Bash window, you can enter the git command lines that appear in the Bitbucket documentation.

  4. Configure your username using the following command, replacing Emma's name with your own. Copy and paste the code after the $ and press enter.

    $ git config --global "Emma Paris"
  5. Configure your email address using the following command, replacing Emma's email address with your own.

    $ git config --global ""

Step 2. (Optional) Install the Git credential helper on Windows 7 or 8

Bitbucket supports pushing and pulling over HTTP to your remote Git repositories on Bitbucket. Every time you interact with the remote repository, you must supply a username/password combination.  Instead of supplying the combination with every HTTP call, you can store these credentials in your OSX keychain, provided you have the git-credential-winstore helper added to Git.  

The helper asks for your username/password on the first Git operation and then stores the credential. Future operations won't require you to supply a username/password combination. To install the helper, do the following in your Windows 7 or 8 (.NET4.0 required) environment:

  1. Download the git-credential-winstore application.
  2. Make a note of where you downloaded the application.
  3. Start the Git Bash shell.
  4. In the shell, change directory to the directory with the git-credential-winstore download.
  5. Install the credential helper by entering the following at the command line.

    ./git-credential-winstore -i /bin/git

    The command updates your global Git configuration.

Step 3. Install Mercurial

TortoiseHg 2.2.1 is the Microsoft Windows version of Mercurial. 

  1. Download the all-in-one installer (MSI version) from the Bitbucket repository (shameless promotion (wink)) .

    If you downloaded the file to a folder on your local machine, you can also click the downloaded file's icon to run the installer. When you've successfully started the installer, you should see the TortoiseHg Setup wizard screen:

    The version shown on your screen may be different than the one shown here of course. That is ok as long as you are installing a TortoiseHg that supports Mercurial version 1.7 or later.

  2. Press Next to move to the next page of the wizard.
    The setup displays the license agreement.

  3. Press Next to accept the license agreement and continue.
    For this setup, use all the default setup values recommended by installer.

  4. To accept all the defaults, press Next on each page of the dialog that comes after the license agreement until the wizards prompts you to install.

  5. Press Install to install the software.
  6. Press Finish on the final page of the dialog to complete the installation.
    You may need to restart your system for the installation to take effect.

Do the following to configure your global default username and email:

  1. Right-click in your Desktop to open the context menu.
    The system displays the right hand context menu:
  2. Click the Hg Workbench item.
    The system opens the TortoiseHg Workbench application.

  3. Choose File > Settings to open the TortoiseHg Settings dialog.
  4. Locate the Commit section on the left hand side and click it.
  5. Fill in the Username value using the following format:
    firstname lastname<email>

    When done the dialog looks similar to this:
  6. Press OK to save your changes.

Step 4. Install PuTTYgen and configure PuTTY

PuTTYgen is a free RSA and DSA key generation tool. You'll learn more about RSA, DSA, and key generation later in this tutorial. If you don't have PuTTYgen or PuTTY installed, follow the instructions below to download, install, and configure the tools:

  1. Download the proper version of the utilities for your system – each one is a single executable file. 
  2. Move the puttygen.exe executable to the C:\Program Files\TortoiseHg folder.
  3. Start Putty.
    The PuTTy Configuration dialog displays. Use this dialog to configure your PuTTy sessions. 
  4. Under the Session node, select Default Settings and press Load.
    This allows you to edit the Default Settings session configuration. 
  5. Under the Connection node, click SSH.
     The Options controlling SSH connections display.
  6. Check Enable compression.
    This option can improve performance of a low-band connection. 
  7. Click the Session node, select Default Settings and press Save.
  8. Click the Close button (red x).

Next Steps

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

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