Working on BitBucket using Git
Last Updated :
23 Nov, 2021
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 “https://[email protected]/USERNAME/REPOSITORY_NAME.git”. 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 https://[email protected]/USERNAME/REPOSITORY_NAME.git

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
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
4 min read
Working on Git for GUI
Git has its native environment within the terminal. All the new features are updated first at the command line, and only there is the full power of Git. But plain text isn't the simplest choice for all tasks; sometimes some users are much more comfortable with a point-and-click interface, a visual r
4 min read
Working with submodules in JGit
Git submodules are the way to include the repository as the subdirectory of another repository. It can be useful for including the external projects within the main project while keeping their versioning independent. JGit is the pure java library for the Git functionalities and it can allowing to ma
3 min read
Using Git on CommandLine
Git is very important and powerful tool when it comes to the software development life cycle. Now in this article, we are going to see why git is used vastly in the software industry and what kinds of operations we can perform with git. So git is basically a distributed version control system for tr
5 min read
Using Bitbucket as an extension to GitHub capabilities
In version control, GitHub and Bitbucket are two of the most prominent platforms. While both offer robust features for managing code repositories, they each bring unique strengths to the table. By integrating Bitbucket with GitHub, you can extend the capabilities of your development workflow, using
2 min read
States of a File in Git Working Directory
Git is a powerful version control system that helps developers track changes in their code over time. Understanding the different states a file can be in within the Git working directory is important for effectively managing and organizing your project. This article will explore the various states o
3 min read
Working With Git Repositories
Git is a powerful and widely-used version control system that helps developers manage their codebases efficiently. By using Git repositories, developers can track changes, collaborate with others, and maintain a history of their projectâs development. In this article, we will learn about working wit
7 min read
How To Create Branch In Git?
Creating branches in Git is a fundamental skill for any developer. Branches allow you to work on different features, bug fixes, or experiments in isolation from the main codebase. This way, you can keep your main branch stable while making changes on separate branches. In this article, weâll guide y
2 min read
How to Ignore a File in Git?
In this article, we are going to discuss how to ignore files in Git. Essentially, you can ignore files by specifying them in the ".gitignore" file. Moreover, you can also ignore directories using this method. Throughout this article, we'll cover everything from creating a GitHub account to setting u
3 min read
Best Tools And Extensions For Working With Git.
Git has become the go-to version control system for developers worldwide, enabling efficient collaboration, version tracking, and code management. Whether you're working on a solo project or part of a larger team, having the right tools and extensions can enhance your Git workflow. In this article,
11 min read