Bitbucket Cheatsheet
#
Bitbucket is a code hosting platform that provides Git repository management, code reviews, and CI/CD features for software development.
General Commands
#
Command/Option | Example | Description |
---|
git clone <repo_url> | git clone https://bitbucket.org/user/repo.git | Clone a repository from Bitbucket |
git fetch | git fetch origin | Fetch changes from the remote repository |
git pull | git pull origin main | Pull changes from the remote repository and merge |
Branch Management
#
Command/Option | Example | Description |
---|
git branch | git branch | List all branches in the repository |
git branch <branch_name> | git branch feature-branch | Create a new branch |
git checkout <branch_name> | git checkout feature-branch | Switch to a different branch |
git merge <branch_name> | git merge feature-branch | Merge a branch into the current branch |
git branch -d <branch_name> | git branch -d feature-branch | Delete a branch |
Commit Management
#
Command/Option | Example | Description |
---|
git add <file> | git add . | Add files to the staging area |
git commit -m "message" | git commit -m "Add new feature" | Commit changes with a message |
git push | git push origin main | Push changes to the remote repository |
Pull Requests
#
Command/Option | Example | Description |
---|
git push origin <branch_name> | git push origin feature-branch | Push a branch to Bitbucket to create a pull request |
bitbucket pr create | bitbucket pr create --title "New Feature" --source branch_name --destination main | Create a new pull request |
bitbucket pr list | bitbucket pr list | List all pull requests |
bitbucket pr merge <pr_id> | bitbucket pr merge 123 | Merge a pull request |
bitbucket pr decline <pr_id> | bitbucket pr decline 123 | Decline a pull request |
Repository Settings
#
Command/Option | Example | Description |
---|
bitbucket repo list | bitbucket repo list | List all repositories |
bitbucket repo create <repo_name> | bitbucket repo create my-repo | Create a new repository |
bitbucket repo delete <repo_name> | bitbucket repo delete my-repo | Delete a repository |
Access Management
#
Command/Option | Example | Description |
---|
bitbucket user list | bitbucket user list | List all users in the repository |
bitbucket user add <user> | bitbucket user add user@example.com | Add a user to the repository |
bitbucket user remove <user> | bitbucket user remove user@example.com | Remove a user from the repository |
CI/CD Pipelines
#
Command/Option | Example | Description |
---|
bitbucket-pipelines.yml | image: node:12\npipelines:\n default:\n - step:\n name: Build\n script:\n - npm install\n - npm test | Example configuration file for Bitbucket Pipelines |
bitbucket pipelines | bitbucket pipelines | View the status of pipelines |
This cheatsheet covers the most commonly used Bitbucket commands and options, helping you manage repositories, branches, commits, pull requests, settings, access, and CI/CD pipelines effectively.