Learn this BitBucket Tutorial and Discover a GitHub Alternative

Published:3 May 2022 - 6 min. read

Azure Cloud Labs: these FREE, on‑demand Azure Cloud Labs will get you into a real‑world environment and account, walking you through step‑by‑step how to best protect, secure, and recover Azure data.

In today’s DevOps space, working with dozens of applications and even more configurations file is the norm. And to manage these artifacts, you’ll need a repository. No one can blame you if the first word you think of is GitHub (that is what we will learn from this BitBucket Tutorial article).

Apart from GitHub, Bitbucket is an excellent alternative. Bitbucket allows you to store code or configuration files and collaborate with team members. Bitbucket also integrates well with Jira and Trello to bring the entire software team to execute a project.

In this tutorial, you will learn to install and configure a Bitbucket server on Ubuntu. Set up a new project and repository, and test your Bitbucket instance with Git Bash on Windows.

Prerequisites

This post will be a step-by-step BitBucket tutorial. To follow along, be sure you have the following.

  • A Windows 10 computer with Git Bash installed.

Although this tutorial covers Bitbucket on Ubuntu, know that Bitbucket is also available in Windows and other Linux distros.

Installing the Bitbucket Server

This tutorial kicks off with installing the Bitbucket Server. Installing Bitbucket is nothing different from installing other packages on your machine, and you only need to run a few Linux commands. To install, follow the below steps.

1. Log in to your Ubuntu machine using your favorite SSH client.

2. Update your computer’s package repository cache by running the below command.

sudo apt update

3. Next, run the following commands to create a directory named /opt/install-bitbucket-demo and switch to that directory. This directory will host your Bitbucket installation files.

sudo mkdir /opt/install-bitbucket-demo
cd /opt/install-bitbucket-demo
Creating the Bitbucket tutorial directory
Creating the Bitbucket tutorial directory

4. Now, download the Bitbucket binary file for Linux 64-bit by running the below wget command.

As of this writing, the latest Bitbucket version is 7.21.0. In the future, you may find the latest download links on the Bitbucket products download page.

sudo wget https://www.atlassian.com/software/stash/downloads/binary/atlassian-bitbucket-7.21.0-x64.bin

Wait for the download to finish. The installer size is approximately 496MB, and the download may be complete in a few minutes, depending on your internet speed.

Downloading the Bitbucket binary file
Downloading the Bitbucket binary file

5. After downloading, turn the binary file into an executable by running the following command.

# Adding the Execute permission on the binary file
sudo chmod a+x atlassian-bitbucket-7.21.0-x64.bin

6. Run the below command to install the Bitbucket server.

Starting the Bitbucket installation with sudo creates a dedicated account that will run Bitbucket and allows running Bitbucket as a service.

sudo ./atlassian-bitbucket-7.21.0-x64.bin

7. When the Bitbucket installation wizard prompts you to install or upgrade an instance, press 1, Enter for a new Bitbucket instance installation.

Choosing to install a new instance
Choosing to install a new instance

8. The wizard asks you What type of instance are you looking to install? Press 1, Enter to Install a Server instance.

Choosing to install a server instance
Choosing to install a server instance

9. Next, leave the default installation path for Bitbucket (/opt/atlassian/bitbucket/7.21.0] and press Enter.

Setting the Bitbucket installation path
Setting the Bitbucket installation path

10. Leave the default home directory (/var/atlassian/application-data/bitbucket) unchanged and press Enter. This directory will host the Bitbucket repositories, plugins, and other data related to Bitbucket.

Setting the Bitbucket home directory.
Setting the Bitbucket home directory.

11. Accept the default port number (7990) and press Enter on the port number configuration step.

Setting the Bitbucket port number
Setting the Bitbucket port number

Bitbucket also uses port numbers 7992 and 7993 to run the search server, enabling the search functionality.

12. On the Install Bitbucket as a service prompt, press y, Enter. The installer configures Bitbucket to run as a daemon and starts automatically when the computer restarts.

Choosing to install Bitbucket as a service
Choosing to install Bitbucket as a service

13. Review the Installation summary and press i, Enter to confirm the installation. Wait for the installation to complete, which only takes a few minutes.

Confirming the Bitbucket installation settings
Confirming the Bitbucket installation settings

14. When the installation is complete, press y, Enter to launch Bitbucket.

Launching Bitbucket
Launching Bitbucket

15. Finally, press n, Enter to skip launching the browser.

Skip launching the browser
Skip launching the browser

Setting up the Bitbucket Server Configuration

So you’ve installed Bitbucket. Excellent! But, there are a few more steps before you start using Bitbucket. Don’t worry. You’ll be doing the Bitbucket setup through the web UI as follows.

1. Now open your favorite browser and navigate to HTTP://ipaddressOrHostname:7990, and you should see the Bitbucket setup screen as shown below. Select the Language as English and Database as internal, and click on the Next button.

Choosing the language and database type
Choosing the language and database type

2. Specify the Application title, and the base URL will auto-populate. Next, select the I need an evaluation license option and click on the I have an account button.

Setting up Licensing and base URL
Setting up Licensing and base URL

3. On the next page, log in to your Atlassian account. Depending on how you registered your account, select the appropriate login option.

Atlassian account login page
Atlassian account login page

4. Select the following options on the New Trial License page and click Generate License to generate a 90-day trial license.

  • Product: Bitbucket Software.
  • License type: Bitbucket Software (Data Center).
  • Organization: <Your organization name>.
  • Your instance: up and running.
  • Server ID: DO NOT CHANGE. The Bitbucket setup automatically populates this field with your server’s Server ID.
Generating a 90-day trial license for Atlassian Bitbucket
Generating a 90-day trial license for Atlassian Bitbucket

5. Click Yes on the confirmation prompt to install the license key to your Bitbucket server.

Confirming the license installation
Confirming the license installation

6. Next, set up the administrator account to completely control the Bitbucket server. Enter your registered email address, username, and password, and click on the Go to Bitbucket button.

Creating the Bitbucket administrator account
Creating the Bitbucket administrator account

7. You should now see the Welcome to Bitbucket. Let’s get started page, which means you’ve completed the Bitbucket server setup stage.

Creating a New Project and Repository

You’ve installed Bitbucket and completed the server configuration, including installing a trial license. Your Bitbucket server is now functional, and you are now ready to start creating create projects and repositories.

1. On the Bitbucket welcome page, click on Projects.

Bitbucket welcome page
Bitbucket welcome page

2. Now, select the Create project option to create the first project.

Selecting the Create project Option
Selecting the Create project Option

3. Next, specify the details for your new project. This example project will have the following information:

  • Project name: ATA Learning
  • Project Key: Automatically populated ( Short form of Project name AL)
  • Description: This is a new project
  • Project avatar: (Optional)

Once you’re satisfied with the project details, click Create project.

Specifying the details to create the project
Specifying the details to create the project

4. Once you’ve created the project, you will see that the Project page has no repositories. To make the one, click on Create repository.

Creating a new repository
Creating a new repository

5. Next, enter the new repository details. This example will create a repository with the below details.

  • Name: Repo1.
  • Default branch name: main.
  • Description: My First Repository in ATA learning Project

Once you’ve filled in the details, click Create repository

Specifying the new repository details
Specifying the new repository details

After creating the repository, you will see the new repository (Repo1) on the list.

Viewing the new repository in ATA Learning Project in bitbucket
Viewing the new repository in ATA Learning Project in bitbucket

Testing the Bitbucket Server with Git Bash

You’ve created a new Bitbucket project and repository. Good! But your repository is sitting there doing nothing at this point. Why not put your repository to use next by cloning it and pushing new files.

1. Firstly, navigate to the Repositories drop-down button at the top of the page and select the repository (Repo1) that you want to clone.

2. Next, click on the Settings button —> Repository permissions —> Enable on the repository page. This step will allow you to clone the repository to your local machine.

Enabling the clone permissions on the Bitbucket repository
Enabling the clone permissions on the Bitbucket repository

3. Now, create a folder on your desktop named New folder.

4. Open Git Bash software on your computer and navigate to the New folder you created in the previous step.

5. Execute the git clone command to clone the Bitbucket repository.

git clone http://ipAddressOrHostname:7990/scm/al/repo1.git
Cloning the repository
Cloning the repository

6. Next, verify if the repository has been cloned successfully by navigating the New folder. As you can see below, the repository has been successfully cloned (repo1) in the New folder.

Verifying the cloned repository
Verifying the cloned repository

That’s it! Your Bitbucket instance is now working. At this point, you can add files to your local repository, commit the changes, and push the changes to your Bitbucket repository.

Conclusion

In this tutorial, you learned to install Bitbucket on Ubuntu and configured its initial settings to get started. You also created a project and a repository within, letting you store code and configuration files conveniently for you and your team.

Finally, you cloned the Git repository using Git Bash on your local machine. With what you’ve learned in this Bitbucket tutorial, do you think Bitbucket could be an excellent alternative to GitHub for your team?

Hate ads? Want to support the writer? Get many of our tutorials packaged as an ATA Guidebook.

Explore ATA Guidebooks

Looks like you're offline!