Bitbucket Cheat Sheet

Below is a cheat sheet for Bitbucket, a web-based platform for version control using Git:

Repository Basics

  • Create a Repository:
    • Click on the “+” icon on the Bitbucket dashboard and select “Repository.”
  • Clone a Repository:
    • Clone a repository to your local machine using:
git clone <repository_url>

Git Basics

Initialize a Repository:

  • Create a new Git repository in the current directory:
git init

Add and Commit:

  • Stage changes:
git add .
  • Commit changes:
git commit -m "Commit message"

Push Changes:

  • Push committed changes to Bitbucket:
git push origin <branch_name>

Pull Changes:

  • Pull changes from Bitbucket to your local repository:
git pull origin <branch_name>

Branching and Merging

Create a Branch:

  • Create a new branch:
git branch <branch_name>

Switch Branch:

  • Switch to a different branch:
git checkout <branch_name>

Merge Branches:

  • Merge changes from one branch to another:
git merge <source_branch> <target_branch>

Pull Requests

  • Create a Pull Request:
    • Open Bitbucket, go to the “Pull requests” tab, and click “Create pull request.”
  • Review and Merge:
    • Review the pull request and merge it if approved.

Branching Strategies

  • Forking:
    • Fork a repository to create your copy for making changes.
  • Feature Branch Workflow:
    • Create feature branches for new features or bug fixes.
  • Gitflow Workflow:
    • Implement Gitflow for a more structured branching model.

Issues and Bug Tracking

  • Create an Issue:
    • Use the “Issues” tab to create and track issues.
  • Link Issues to Commits:
    • Mention issue key in commit message to link it.

Collaboration

  • Add Collaborators:
    • Grant repository access to other users.
  • Code Reviews:
    • Use pull requests for code reviews.

Repository Settings

  • Repository Settings:
    • Adjust repository settings on the Bitbucket website.

Authentication

  • SSH Key Setup:
    • Set up SSH keys for secure authentication.

Integration

  • Integrate with CI/CD:
    • Integrate Bitbucket with CI/CD tools like Jenkins.

Bitbucket Pipelines

  • Configure Pipelines:
    • Set up Bitbucket Pipelines for automated builds.

Git LFS (Large File Storage)

  • Track Large Files:
    • Use Git LFS to handle large binary files.

Bitbucket Server

  • Bitbucket Server (Self-hosted):
    • For self-hosted solutions, set up Bitbucket Server.

Bitbucket provides a range of features beyond this cheat sheet. Be sure to explore the documentation and community resources for in-depth information and updates.