Today we are going to discuss how to configure and manage a Bitbucket repository on our Linux system. I am using Ubuntu 20.04 for this guide and make sure all commands are available for all related systems except Debian. The main reason is that you shouldn’t implement instructions on a Debian system to avoid dependency problems.
What is GIT?
The simplest answer right now is that Git is a version control system to remotely manage files and keep track of all changes. Unlike Git, BitbBucket is a platform that helps keep these files on the server. BitBucket offers both self-hosted and cloud options, but we’ll only be using the cloud version, which is freely available for teams of up to 5 users.
I’ll explore Git and BitBucket separately in future articles. For the latest tips and tricks, visit linuxways.net regularly.
The important things first
As always, we should make sure that Git is available on your system. I’m running the following command to make sure I have the latest stable version of Git on my Ubuntu 20.04 LTS system.
$ git --version
The command will display your latest available Git version. In my case it is 2.25.1 as shown below:
Connect and configure Bitbucket
Step 1. Now we’re going to connect and use the free Bitbucket cloud as a sample repository, but you can also use any other free service like GitHub. This repository is only used for testing purposes. You can use any existing remote GIT repository instead. Skip to step 4 if you already have a remote GIT repository that you want to connect to.
You’ll have a dashboard similar to the one below once you’ve successfully logged in:
Step 2: We then create a repository in our BitBucket cloud.
Step 3. Once a repository has been created, let’s go to the repository settings to connect to Git locally.
Step 4. First, clone the repository using the clone link that can be found on the top right of the project page.
In our case the git command is:
$ git clone https://[email protected]/username/reponame.git
You have to update Username and substitute agree with yours.
The whole scenario will work out similarly as follows:
Now enter the following command to list your accessed directory on your system
Step 5. Now let’s go to our repository folder, create a new file and move it to the origin which is Bitbucket.
1. Enter the following command to change the directory
2. Now create a new file with the following command
$ touch update.md
3. We edit the file in nano as shown below
$ nano update.md
4. After saving, we transfer our changes to the Bitbucket repository with the following commands.
$ git add * $ git commit -m “update” $ git push origin master
These will transfer all changes to our Bitbucket repository.
In this tutorial we learned how to create a repository on Bitbucket, get it, modify it and push it locally. We also used other software like the nano editor.