How to use Bitbucket and Sourcetree

Bitbucket is a version control system. A version control system (VCS) is where programmers can store their code at various stages of development, so that they can restore previous versions easily when there is a requirement. Bitbucket is based on Git, which is one of the most popular VCS. Git was created by Linus Torvalds, who also created the Linux operating system.

Bitbucket can be used either as a cloud-based VCS repository or installed as an in-house application within an organization where the development teams can store their source codes. The main advantage is that it helps much with collaboration among the developers.

In this introductory tutorial, let us see how to create a repository on the Bitbucket cloud and use it for storing source files.

Registration at Bitbucket Cloud and Installation of Sourcetree

To start with, you need to create an account at

1] Login to and click on “Get it free” to sign up for new id or login with a gmail / Microsoft / Apple ids if you do not have a previously registered login.

2] Specify a username for bitbucket cloud and click continue.

3] Once you login to bitbucket cloud, the welcome screen shows the option to create new repository or import existing repository. Also, there is a button to create workspace for team collaboration.

4] Sourcetree is a GUI client for Bitbucket. This is an equivalent of the Git command line client. Sourcetree can be downloaded from Click on the Download button and accept the agreement check mark followed by clicking on Download button again.

5] Double click on downloaded binary to launch the installation of Sourcetree. During the installation process, in the popup window, click on “Bitbucket” icon and click Next. The same registration id used previously with bitbucket has to be used in order to connect sourcetree client with bitbucket cloud.

6] Once login to bitbucket is successful, a “Registration complete!” message appears. Click “Next” to continue with the installation of client tools. Select “Git” and unselect “Mercurial” and click “Next”.

7] Once the Git client installation is done, “Tool installation completed.” message appears. Click Next and in the following Preferences window, enter the bitbucket username and the email id used for bitbucket cloud registration. This will finish the installation process and open sourcetree application window.

Create a repository

1] At Bitbucket click on “Create repository” button

In the “Create a repository – Bitbucket” window, enter the project name, repository name, check the access level as “Private repository” and other settings as indicated below and then click “create repository”

2] The new bitbucket repository is created. In the next window, it displays a command “git clone https://….git“. This command can be used to clone this repository if the Git command line client is used. We can use the URL (the value after git clone i.e., https://……git) will have to be used to specify the remote repostory’s URL at sourcetree.

3] At Sourcetree, click on “+” icon (Create) in order to create a local repository. The folder where repository files are stored can be specified either by entering it at the specified text box or by exploring the filesystem by clicking at the “BROWSE” button. Also specify the name of the repository and the type of version control system (Git) and then click “Create” button.

4] Click “yes” if a prompt appears asking for confirmation to create the repository at the specified folder. Once the repository is created, a hidden folder called “.git” will appear at the repository folder. The .git folder contains configuration settings associated with the Git client. Don’t touch this hidden directory for now.

Adding and Updating Files to Repository

5] Create a new text file called Testing1.txt at the local folder designated for the repository and add some content to it. Then save it.

6] As soon as the new file is added, the sourcetree shows it as “Uncommitted changes” and the filename appears under “Unstaged files”. select the filename and click on “Stage selected”. The filename now appears under “Staged files”.

7] Click the “commit” icon in the top. Specify few comments such as “First commit” in the text box at the bottom of the window and click on the “Commit” button below. This might prompt to confirm the full name and email id. Click ok after verifying the values.

8] From the top menu, select “Repository -> Repository Settings”. This will open the “repository settings” popup window.

9] Click “Add” button and then specify the URL (as specified in step 2 above) and remote name as well as the bitbucket account name and click OK. Again, click OK at the next prompt.

10] At the local folder associated with the repository, add another file called “”, add few introductory contents to it and then save it. At the sourcetree, stage the new file and click on “Commit” icon. Add a comment about reason for this commit and then click on “Commit” button.

11] At sourcetree, click on “Push” button. This will open a new popup window. Check the box which indicates local branch as “master” and specify remote as “master” and then click “Push”. At the CredentialHelperSelector window, select “manager-core” and check the box “Always use this from now on”. The files get pushed to remote now.

12] Refresh Bitbucket and open source and verify if the files are listed under master branch.

Scroll to Top