Create and clone a repository

If you're starting from scratch and have no files, you can simply create a repository on Bitbucket Cloud and then clone it to your local system. This cloning action connects your remote Bitbucket repo to your specified local directory.

This page

Step 1: Create a repository on Bitbucket

To create a repository, do the following:

  1. Log into Bitbucket Cloud under your individual account.
  2. Click Repositories > Create repository or the Create new repository link.
  3. Choose a repository Owner
    This only appears if you are creating under an account with membership in one or more teams. 
  4. Enter a Name and Description for your repository.
  5. Tick Private if you want to hide your repository from the general public, so that only selected people can see it.
  6. Select the Repository type.
  7. Click Create repository.

If you create a repository with mixed upper and lower case name, Bitbucket converts the name to all lower case in the repository URL. The name appears in mixed case in the UI. You cannot create two repositories with names that result in the same URL.

After you create a repository, Bitbucket provides you with a help panel. This help panel is an easy way to get command tips for moving forward.

Step 2: Clone the repository to your local system

When you clone a repository, you create a copy of your Bitbucket repository on your local system. Cloning also connected the remote and local repositories so that you start pushing and pulling changes between both places. Check out the next sections for the best way to clone your repository:

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 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 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.

Where do you go next?

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