Bitbucket: Git Repository Management
Bitbucket is Atlassian's Git-based repository management solution designed for professional software teams. It combines source control, code review, and CI/CD capabilities while integrating tightly with the broader Atlassian ecosystem, including Jira and Confluence. This post walks through the core concepts and practical workflows for managing Git repositories in Bitbucket.
Why Bitbucket?
While several Git hosting platforms exist, Bitbucket stands out for teams that:
- Already rely on Jira for issue tracking and want native integration.
- Need both cloud and self-hosted (Data Center) deployment options.
- Want built-in CI/CD through Bitbucket Pipelines.
- Require granular access controls for enterprise governance.
Getting Started
Creating a Repository
You can create a repository through the web UI or the API. From the dashboard, select Create > Repository, then configure:
- Project: A logical grouping for related repositories.
- Repository name: Used to generate the clone URL.
- Access level: Private by default (recommended).
- Include README / .gitignore: Optional starter files.
Once created, clone it locally:
git clone https://bitbucket.org/your-workspace/your-repo.git
cd your-repo
For SSH access, add your public key under Personal Settings > SSH Keys:
git clone git@bitbucket.org:your-workspace/your-repo.git
Branching Strategy
A disciplined branching model keeps repositories maintainable. A common approach:
# Create a feature branch tied to a Jira issue
git checkout -b feature/PROJ-123-add-login
# Stage and commit with a smart commit message
git add .
git commit -m "PROJ-123 Add login form validation"
# Push to Bitbucket
git push -u origin feature/PROJ-123-add-login
Tip: Including the Jira issue key (e.g.,
PROJ-123) in commit messages links commits directly to the corresponding Jira ticket.
Branch Permissions
Protect critical branches to enforce quality gates. Under Repository settings > Branch restrictions, you can:
- Prevent direct pushes to
mainorrelease/*. - Require a minimum number of pull request approvals.
- Require passing builds before merging.
Pull Requests and Code Review
Pull requests (PRs) are central to collaboration in Bitbucket.
- Push your branch and open a PR targeting
main. - Add reviewers and a description referencing related tickets.
- Reviewers comment inline, request changes, or approve.
- Merge once approvals and build checks pass.
Merge Strategies
Bitbucket supports several merge strategies:
| Strategy | Description |
|---|---|
| Merge commit | Preserves full branch history |
| Squash | Combines all commits into one |
| Fast-forward | Linear history, no merge commit |
Configure the default under Repository settings > Merge strategies.
Automating with Bitbucket Pipelines
Pipelines lets you define CI/CD directly in the repository using a bitbucket-pipelines.yml file:
image: node:18
pipelines:
default:
- step:
name: Build and Test
caches:
- node
script:
- npm install
- npm run lint
- npm test
branches:
main:
- step:
name: Deploy to Production
deployment: production
script:
- ./deploy.sh
Pipelines run automatically on push, providing immediate feedback on build and test status.
Access Management Best Practices
- Use workspaces and projects to organize teams and repositories.
- Apply the principle of least privilege with repository- and project-level permissions.
- Prefer app passwords or OAuth tokens over account passwords for automation.
- Regularly audit access via the admin dashboard.
Conclusion
Bitbucket offers a robust, integrated platform for Git repository management—especially valuable for teams invested in the Atlassian ecosystem. By combining structured branching, enforced code review, protected branches, and native CI/CD through Pipelines, teams can maintain high code quality while accelerating delivery. Start small with branch permissions and pull requests, then layer in automation as your workflow matures.
Top comments (0)