Today we are going to discuss how to configure and manage a Bitbucket repo on our Linux system. I am using Ubuntu 20.04 for this guide, and I’ll make sure that all commands are readily available for all related systems except Debian. The main reason is that you should not implement instructions on a Debian system to avoid any dependency issues.
What is GIT?
The simplest answer, for now, is that Git is a version control system to manage files remotely and keep track of all the changes. Unlike Git, BitbBucket is a platform that helps to keep those files on the server. BitBucket has both self-hosted and cloud options, but we are only going to use the cloud version which is freely available for teams of up to 5 users.
I will keep exploring Git and BitBucket separately in future articles. For the latest tips and tricks keep visiting linuxways.net regularly.
First things first
As always we should make sure that Git is available on your system. I’ll run the following command to make sure that 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 will proceed to connect and use the free Bitbucket cloud as an example repository, but you can use any other free service like GitHub as well. This repository is just used for testing purposes, you can use any existing remote GIT repository instead, proceed with Step 4 if you have already a remote GIT repo that you like to connect to.
You will have a similar dashboard as below once signed up successfully:
Step 2: We’ll then create a repository in our BitBucket cloud.
Step 3. Once a repository is created, we will go to the repository settings to connect with Git locally.
Step 4. First clone the repository using the clone link which you will find on top right of the project page.
In our case, the git command will be:
$ git clone https://[email protected]/username/reponame.git
You must update username and reponame to match with yours.
The whole scenario will go similar to following:
Now type the following command to list your fetched directory on your system
Step 5. Now we’ll go to our repository folder, create a new file, and push it to the origin which is Bitbucket.
1. Type following command to change the directory
2. Now create a new file using following command
$ touch update.md
3. We’ll edit the file in nano as shown below
$ nano update.md
4. Once saved we’ll push our changes to the Bitbucket repository using the following commands.
$ git add * $ git commit -m “update” $ git push origin master
These will push all the changes to our Bitbucket repository.
In this tutorial, we learned how to create a repository on Bitbucket, fetch it, modify, and push it locally. We also used some other software like nano editor.