Clone a repository

When you want to work on a project by changing its files or adding new files, you need to clone your project to your local system. 

Cloning a Git repository

You can use SourceTree, Git from the terminal, or any client you like to clone your Git repository. These instructions show you how to clone your repository using Git from the terminal.
  1. Navigate to the repository in Bitbucket.
  2. Click the Clone button.
  3. Copy the clone command (either the SSH format or the HTTPS).
    If you are using the SSH protocol, ensure your public key is in Bitbucket and loaded on the local system to which you are cloning.
  4. Launch a terminal window.
  5. Change to the local directory where you want to clone your repository.
  6. Paste the command you copied from Bitbucket, for example:

    Clone over HTTPS:
     $ https://username@bitbucket.org/teamsinspace/documentation-tests.git


    Clone over SSH:
    $ git@bitbucket.org:teamsinspace/documentation-tests.git


If the clone was successful, a new sub-directory appears on your local drive. This directory has the same name as the Bitbucket repository that you cloned. The clone contains the files and metadata that Git requires to maintain the changes you make to the source files.

Cloning a Mercurial repository

You can use Sourcetree, TortoiseHg, Mercurial from the terminal, or any client you like to clone your Mercurial repository. These instructions show you how to clone your repository using Mercurial from the terminal.
  1. Navigate to the repository in Bitbucket.
  2. Click the Clone button.
  3. Copy the clone command (either the SSH format or the HTTPS).
    If you are using the SSH protocol, ensure your public key is in Bitbucket and loaded on the local system to which you are cloning.
  4. Launch a terminal window.
  5. Change to the local directory where you want to clone your repository.
  6. Paste the command you copied from Bitbucket, for example:

    Clone over HTTPS:
     $ https://username@bitbucket.org/teamsinspace/hg-documentation-tests
    Clone over SSH:
    $ ssh://hg@bitbucket.org/teamsinspace/hg-documentation-tests

If the clone was successful, a new sub-directory appears on your local drive. This directory has the same name as the Bitbucket repository that you cloned. The clone contains the files and metadata that Mercurial requires to maintain the changes you make to the source files.

Cloning a repository with SourceTree

Whether you are using Git or Mercurial, you can use SourceTree to clone your repository. If you aren't familiar with SourceTree, it's our client that provides an alternative to the command line. Follow these instructions to clone your repository.

  1. Navigate to the repository in Bitbucket.
  2. Click the Clone button.
  3. Copy the clone command (either the SSH format or the HTTPS).
    If you are using the SSH protocol,  you must make sure your public key is in Bitbucket and loaded on the local system you are cloning to.
  4. Launch Sourcetree.
  5. Click the Add Repository button and pick Clone from URL.
  6. Enter a Destination Path.
    This is the folder where your clone is added to your local system.
  7. Paste the clone command you copied from Bitbucket. 
    At this point, the dialog should look similar to the following:
  8. Press Clone
    Sourcetree creates the folder on your local system. You can use the Sourcetree to interact with the repository.

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