Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Git Tutorial
  • Git Exercises
  • Git Basic Commands
  • Git Cheat Sheet
  • Git Interview Questions
  • Git Bash
  • GitHub
  • Git Branch
  • Git Merge
  • Git WorkFlow
  • Git Hooks
  • Git LFS
  • Git Rebase
  • Git Cherry Pick
Open In App
Next Article:
Working on BitBucket using Git
Next article icon

Working on BitBucket using Git

Last Updated : 23 Nov, 2021
Comments
Improve
Suggest changes
Like Article
Like
Report

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 initgit initialization.
git add --allThis 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 masterPush the files into your Bitbucket repository

Next Article
Working on BitBucket using Git

S

shrivastavasanatan
Improve
Article Tags :
  • Git

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
    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
    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
    Bare Repositories in Git
    Repositories in Git are a snapshot of the folder in which you are working on your project. You can track the progress and changes made to the project by making commits and also revert changes if not satisfactory. Repositories can be divided into two types based on the usage on a server. These are: N
    7 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences