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.
Step 1. Install Git
You can use Git from the command line or you can use one of several GUI-based tools such as Sourcetree. These instructions assume you are using Git from the command-line.
- Make sure you have root access (sudo) on the system where you want to install Git.
- Download the Git installer from its official website.
The installer is a DMG file.
- Double-click the DMG to expand it.
- Double-click the PKG file to install it.
The Git installer launches.
- Follow the prompts to install Git.
- Open a terminal on your system.
Verify the installation was successful by typing
which gitat the command line.
Configure your global username using the following command:
git config --global user.name "FIRST_NAME LAST_NAME"
- Configure your global email address using the following command:
git config --global user.email "MY_NAME@example.com"
Git uses the global email address for all your commits. Also, you can set this value per repository (you'll learn more about this later).
Step 2. (Optional) Install the git-credential-osxkeychain helper
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-osxkeychain 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, open a terminal window on your local system and do the following:
Check if you have the helper installed by determining if you get a usage statement for it.
If you receive a usage statement, skip to Step 5. If the helper is not installed, go to the next step.
git-credential-osxkeychainsoftware to your source with curl;
This command downloads the source to a local file called
git-credential-osxkeychain. If you don't have curl installed you can use this link.
Move the file to the
Make the file an executable:
Configure git to use the helper.
Step 3. Install Mercurial
You can use Mercurial from the command line or you can use one of several GUI-based tools such as Sourcetree. These instructions assume you are using Mercurial from the command-line.
- Make sure you have root access (sudo) on the system where you want to install Mercurial.
- Download the Mercurial installer from its official website.
The installer is contained in ZIP file.
- Double-click the ZIP file to expand it.
- Double-click the MPKG file to run the installer.
- Follow the prompts to complete the installation.
- Open a terminal window.
Verify the installation was successful by typing the following at the command line.
Hg is the chemical symbol for Mercury and
hgis the command for mercurial.
Determine if you already have a
~/.hgrcfile in your environment by entering the following at the command line:
If for some reason, you don't have the
.hgrcfile, you should create one yourself using the touch command:
- Open the Mercurial configuration file
~/.hgrcusing your favorite editor.
- Add a
usernamevalue to the configuration.
When you are done, the
~/.hgrcfile looks something like this:
This is default value Mercurial uses, you can also set this for specific repositories (you'll learn more about this later).
- Save and close the .
The next step is to Create an Account and a Git Repo