Open In App

Working on BitBucket using Git

Last Updated : 23 Nov, 2021
Like Article

Git provides various tools and applications to perform better handling of the work environment. Git is a type of version control system that is used to allow more than one developer to access the source code of a specific application and can modify changes to it that may be seen by other developers. BitBucket is a git-based tool that helps with collaborations on large projects across various teams and helps keep a track of different versions of a project that can access it from your local machine. It is specially designed for teams to collaborate on large projects in big enterprises. It is also used for automated testing and deployment of code. Since this is a git-based tool, you need to have git in your system to work with Bitbucket.

Let’s suppose many developers are developing a project that is divided between various teams and will work on different versions during and after development. For this kind of project, Bitbucket is the best option for individuals or teams.

Now you might be wondering that what is the difference between Github and Bitbucket? 

The most elemental difference between Github and Bitbucket is that Github is more public-friendly, and is used by individual developers, whereas Bitbucket is more private-friendly, and hence is used by large-scale enterprises for the development of big projects.

Note Another way to create a repository and clone it is using the source tree in BitBucket.   

Working with BitBucket

Now’s let’s see how we can work with the Bitbucket using git. It’s pretty simple. You will need to create a repository first. Visit the link below and create an account at Bitbucket. After you have created your account, you will see a button “create repository” in the center of the screen, click it and create a repository. You can choose the repository to be private or public. public repositories are accessible to everyone while private is only accessible to you. Now we will get started with the Bitbucket. 

We will need to clone the project folder into your local machine, which can be done in a few steps as shown below with visual aids 

Step 1: Clone the repository into your local machine

Click on the “clone” button on the right corner of the dashboard. A prompt with the URL link would appear. the URL link would look like “”. You can clone using either https or ssh links. 

Step 2: Copy and paste the link in the terminal after typing git clone. 

Use the following commands to clone your repository as provided below as follows:

git clone (REPOSITORY URL)
git clone

Now, we need to know what does clone means? Clone means, it will retrieve all the contents from that directory to your local machine where you are working, without affecting the Bitbucket repository, until you edit it from the terminal. Using git clone would add the folder to your local machine. 

Step 3: Check your progress by typing “git status” command into the terminal 

git status

Step 4: Creating and adding a file to your Bitbucket repository 

Now, let’s suppose you want to create and add a file to your Bitbucket Repository. Type in the commands below in the terminal.

echo "This is a test file" >> file.txt
git add file.txt

Step 5: Committing changes to BitBucket repository 

The file is now added and is ready to be committed and pushed on your Bitbucket repository. 

git commit -m "Initial Commit"
git push origin master // to push the changes on the Bitbucket repository.

If there are some changes made to your repository. You can use the git pull command to restore them to your local machine. 

git pull
git pull origin master 
git pull --all

Any of the three commands would restore the changes into your folder in the local machine. 

Step 6: Performing operations on branches 

As discussed, since this is a tool for working across separate branches, let’s learn how to create, and delete a new branch, and how to switch across branches. 

To create a branch, type in the terminal 

git branch new_branch_name
git branch testbranch // to create a new branch named testbranch

To switch the branch, use the command git checkout

git checkout new_branch_name
git checkout testbranch // to switch to a branch named testbranch

Finally, to merge your branch with the master branch, use the command git merge to merge the two branches. 

git merge branch_name

Step 7: To delete a branch, use git branch -d to delete the branch. 

git branch -d branch_name

In case you have an existing project, switch the current directory to that existing repository in the Terminal or CMD. Then type in the commands below in the terminal or CMD.  

Command  Action performed 
git init git initialization.
git add –all This stages the newly added files and prepares them for commit.
git remote add origin (repository_url) Use the https or ssh URL link from the bitbucket website to connect to remote Bitbucket repository that you want to add the folder into
git commit -m  Initial Commit
git push origin master Push the files into your Bitbucket repository

Similar Reads

Difference Between Git remote prune, Git prune and Git fetch --prune
One of the great things about Git is that it's *very careful about deleting data*. This makes it pretty hard to lose commits or other valuable data in Git! A small downside of this is that you might sometimes see stale data that you actually don't need anymore. One of the best examples of this is references to remote branches that have already been
2 min read
Using Bitbucket as an extension to GitHub capabilities
Prerequisite links suggested for better understanding this article: GIT-Let's Get into it Github to host static page There is a huge open source community backing of GitHub and no matter what, nothing beats GitHub when we talk about user experience and interface, reliability, and everything’s just apt and perfect! There’s a catch! In the free plan
3 min read
Difference Between Bitbucket and GitHub
Bitbucket: Bitbucket is the repository management tool that is specially built for expert teams and professionals. It is also called as Git repository management software and is a central hub for handling all the Git repository. Uses of Bitbucket are access control, workflow control, pull request, and integration for full rest API. Following are so
2 min read
Introduction to BitBucket
BitBucket is a cloud-based service that helps to store and manage their code, as well as track and control the changes to their code. BitBucket provides a cloud-based Git repository hosting service. Additionally, BitBuckets provides a variety of services like it gives teams to collaborate and create projects, test and deploy the code. Table of Cont
4 min read
How to Set Up Git Using Git Config?
Git is a powerful version control system that helps developers manage and track changes in their code. Setting up Git correctly is important for maintaining an organized and efficient workflow. In this article, we'll walk you through the process of setting up Git using the git config command. PrerequisitesBefore we dive into the setup process, make
3 min read
Difference between “git add -A” and “git add”
Git is a free and open-source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. It is basically, software for tracking changes in any set of files, usually used for coordinating work among programmers collaboratively developing source code during software development. Featu
3 min read
Git - Difference Between Git Revert, Checkout and Reset
While Working with Git in certain situations we want to undo changes in the working area or index area, sometimes remove commits locally or remotely and we need to reverse those changes. There are 3 different ways in which we can undo the changes in our repository, these are git reset, git checkout, and git revert. git checkout and git reset in fac
7 min read
Git - git-show Command Line Utility
Git is a free and open-source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. Git relies on the basis of distributed development of software where more than one developer may have access to the source code of a specific application and can modify changes to it that may be
3 min read
Git - git-prune
Git prune is a command that deletes all the files that are not reachable from the current branch. The prune command is useful when you have a lot of files in your working directory that you don’t want to keep. The primary use of git prune is to clean up your working directory after you have finished working on a project. What actually git prune doe
4 min read
Git LFS: Managing Large Files in Git Repositories
Git, undoubtedly one of the most popular version control systems, is widely used for managing source code in software development projects. However, one of its limitations is its handling of large files. Traditional Git repositories struggle to efficiently manage large files, leading to bloated repositories and slow performance. This is where Git L
4 min read
Article Tags :