Bitbucket Pull Request Guide: Create, Review, Approve & Merge
39 people viewed this
Bitbucket Pull Request Guide — Create, Review, Approve & Merge
A Pull Request (PR) is one of the most important parts of a professional Git workflow.
Writing code is only one part of software development. In a team, your code usually needs to be:
- Committed
- Pushed to a remote branch
- Reviewed by other developers
- Tested
- Approved
- Merged into a shared branch
Bitbucket Pull Requests provide a structured way to do this.
The basic workflow is:
Feature Branch
↓
Push
↓
Pull Request
↓
Code Review
↓
Feedback / Changes
↓
Approval
↓
Merge
In this article, we will learn the complete Bitbucket Pull Request workflow using practical PHP and Laravel examples.
1. What Is a Pull Request?
A Pull Request is a request to integrate changes from one branch into another branch.
For example:
feature/payment
↓
Pull Request
↓
develop
The developer is effectively saying:
"These changes are ready for the team to review and potentially merge into the target branch."
The exact terminology and interface can vary by Git hosting platform, but the underlying workflow is the same: review and integrate changes between branches.
2. Why Do We Need Pull Requests?
Imagine a team where every developer directly pushes code into main.
Developer A → main
Developer B → main
Developer C → main
Developer D → main
There is little opportunity for structured review before changes become part of the shared branch.
With Pull Requests:
Developer
↓
Feature Branch
↓
Pull Request
↓
Code Review
↓
Tests
↓
Approval
↓
Target Branch
This creates a controlled collaboration process.
3. Pull Request vs Git Pull
These two terms are frequently confused.
| Pull Request | git pull |
|---|---|
| Collaboration/review workflow on a hosting platform | Git command used to fetch and integrate changes |
| Used for code review and merging | Used to update a local branch |
| Created in Bitbucket/GitHub/etc. | Run in your terminal |
| Can involve reviewers and approvals | Does not itself create a code review |
So:
Pull Request ≠ git pull
4. Complete Bitbucket Pull Request Workflow
A typical workflow is:
1. Update local repository
↓
2. Create feature branch
↓
3. Develop feature
↓
4. Run tests
↓
5. Commit changes
↓
6. Push branch to Bitbucket
↓
7. Create Pull Request
↓
8. Add reviewers
↓
9. Code review
↓
10. Fix requested changes
↓
11. Update Pull Request
↓
12. Resolve conflicts if necessary
↓
13. Approval
↓
14. Merge
↓
15. Delete feature branch if appropriate
5. Step 1 — Start With an Updated Branch
Suppose your team uses develop as its integration branch.
First:
git switch develop
Get the latest changes:
git pull origin develop
Now create your feature branch:
git switch -c feature/payment
6. Step 2 — Develop the Feature
Suppose you are developing a payment feature for a Laravel pharmacy application.
You may create:
app/Services/PaymentService.php
app/Http/Controllers/PaymentController.php
app/Models/Payment.php
database/migrations/xxxx_create_payments_table.php
tests/Feature/PaymentTest.php
Work only on the feature you are responsible for.
7. Step 3 — Test Your Changes
Before creating a Pull Request, run the relevant tests.
php artisan test
You can run a specific test:
php artisan test tests/Feature/PaymentTest.php
Depending on the project, you may also run:
php artisan pint
or other project-specific quality checks.
8. Step 4 — Review Your Changes
Check the working tree:
git status
Review unstaged changes:
git diff
After staging:
git diff --staged
This is important because you don't want to accidentally include unrelated changes in your Pull Request.
9. Step 5 — Commit Your Changes
Create a meaningful commit:
git add .
git commit -m "feat(payment): add payment service"
Good commit messages make the Pull Request history easier to understand.
Examples:
feat(payment): add payment gateway
fix(invoice): correct invoice total
test(payment): add failed payment test
refactor(order): move business logic to service
10. Step 6 — Push Your Branch
Push your branch to Bitbucket:
git push -u origin feature/payment
After this, Bitbucket has your feature branch.
origin
└── feature/payment
11. Step 7 — Create the Pull Request
Open your Bitbucket repository and select the option to create a Pull Request for the branch you pushed.
The important information is:
Source:
feature/payment
Destination:
develop
Always verify the source and destination branches carefully before creating the Pull Request.
12. Source Branch vs Destination Branch
Suppose:
feature/payment
↓
develop
Then:
- Source branch:
feature/payment - Destination branch:
develop
The source contains your changes. The destination is where the changes are proposed to be integrated.
A common mistake is selecting the wrong destination branch.
13. Example — Pull Request for Laravel Feature
Suppose you have implemented:
Payment Gateway Integration
Your Pull Request could be:
Source:
feature/payment-gateway
Destination:
develop
Title:
feat(payment): add payment gateway integration
The reviewer can then inspect your changes before the branch is merged.
14. How to Write a Good Pull Request Title
A PR title should clearly communicate the purpose of the change.
Good examples:
Add payment gateway integration
Fix invoice total calculation
Add customer search API
Improve pharmacy inventory validation
Refactor order processing service
Avoid vague titles:
Changes
Update
Fix
New code
Final changes
15. How to Write a Good Pull Request Description
The description should help reviewers understand the change without reading every line of code first.
A useful structure is:
## Summary
Added payment gateway integration.
## Changes
- Added PaymentService
- Added payment API integration
- Added payment validation
- Added database migration
- Added feature tests
## Testing
- php artisan test
- Payment feature tests passed
## Database Changes
- Added payments table
## Notes
Payment credentials are configured through environment variables.
16. What Should a Reviewer Look At?
A reviewer should not only check whether the code works.
They may review:
- Correctness
- Readability
- Security
- Performance
- Database queries
- Laravel architecture
- Validation
- Error handling
- Test coverage
- Potential regressions
- Code duplication
17. Laravel Code Review Example
Suppose a developer writes:
public function store(Request $request)
{
$payment = Payment::create([
'amount' => $request->amount,
'user_id' => $request->user_id,
]);
return response()->json($payment);
}
A reviewer might ask:
Should validation be handled through a Form Request?
Should payment business logic be moved into a service?
Should user_id come from the authenticated user?
Do we need authorization?
Are there tests for invalid payment amounts?
The purpose of code review is to improve the implementation before it becomes part of the shared codebase.
18. How to Leave a Good Review Comment
A useful review comment should explain the concern clearly.
Instead of:
"Bad code."
Prefer something like:
"Could we move the payment processing logic into
PaymentService? This controller is becoming responsible
for validation, business logic, and gateway communication."
A good review comment is specific and actionable.
19. Types of Review Comments
Common review comments include:
Question
"Could we use the authenticated user here instead?"
Suggestion
"Consider moving this logic into PaymentService."
Bug
"This query may return incorrect results when the customer
has multiple payment records."
Performance
"Could this relationship cause an N+1 query problem?"
Security
"Please avoid accepting user_id directly from the request."
20. Responding to Review Comments
Suppose the reviewer says:
"Please add validation for the payment amount."
You update the Laravel code:
app/Http/Requests/PaymentRequest.php
Run tests:
php artisan test
Commit:
git add .
git commit -m "fix(payment): add amount validation"
Push:
git push
The existing Pull Request is automatically updated with the new commit.
21. Do You Need to Create a New Pull Request?
Usually, no.
If the new commit is pushed to the same source branch, it becomes part of the existing Pull Request.
Existing PR
↑
feature/payment
↑
new commit
This is one reason feature branches are useful.
22. Pull Request Approval
Depending on repository settings and team policy, one or more reviewers may need to approve the Pull Request.
The review process might look like:
Developer
↓
Create PR
↓
Reviewer 1 → Approved
↓
Reviewer 2 → Approved
↓
Required checks pass
↓
Merge
Some repositories may require multiple approvals, while others may have different approval rules.
23. What Does "Changes Requested" Mean?
A reviewer may request changes before the Pull Request can be merged.
For example:
Changes requested:
- Add validation
- Add test for failed payment
- Move business logic to service
You make the changes locally, commit, and push again.
The reviewer can then review the updated code.
24. Pull Request Checks
A Bitbucket repository may have automated checks connected to its workflow.
For example:
Push
↓
Build
↓
Composer install
↓
Run tests
↓
Static analysis
↓
Code quality checks
↓
Result
A Pull Request may require these checks to pass before merging.
25. Laravel CI Example
A Laravel project might run:
composer install
php artisan test
php artisan pint --test
A real project can have additional commands depending on its CI configuration.
The important idea is:
Don't rely only on manual review. Automate repeatable quality checks whenever practical.
26. Pull Request and Merge Conflicts
Suppose your feature branch was created several days ago.
Meanwhile, develop changed significantly.
develop
↓
A---B---C---D---E
feature/payment
\
F---G
The Pull Request may now have conflicts.
You can update your local branch according to your team's preferred workflow.
For example:
git fetch origin
git switch feature/payment
git merge origin/develop
Resolve conflicts, test the application, and push the updated branch.
27. Resolving a Pull Request Conflict
Check:
git status
Open the conflicted file:
app/Services/PaymentService.php
You may find:
<<<<<<< HEAD
Your feature changes
=======
Changes from develop
>>>>>>> origin/develop
Resolve the file manually.
Then:
git add app/Services/PaymentService.php
Complete the merge:
git commit
Run:
php artisan test
Then:
git push
28. Merge vs Squash vs Rebase
Depending on repository configuration, Bitbucket may offer different ways to integrate a Pull Request.
Merge Commit
feature/payment
\
A---B
\
M → develop
The feature history is preserved with a merge commit.
Squash
Multiple feature commits can be combined into a single commit.
A
B
C
↓
SINGLE COMMIT
This can produce a simpler target-branch history.
Rebase and Merge
The feature commits can be replayed on top of the target branch, producing a linear history when appropriate.
The choice should follow your team's repository policy.
29. When Should You Squash Commits?
Suppose your branch contains:
fix typo
test
fix test
debug
final fix
another fix
These commits may represent development noise rather than meaningful project history.
A team may choose to squash them before integrating the feature.
However, don't rewrite shared history or squash commits blindly. Follow the project's contribution rules.
30. Draft Pull Request
If your feature is still under development, a Draft Pull Request can be useful when supported by your Bitbucket workflow.
It communicates:
"This is not ready for final merge yet,
but I want early feedback."
This can be useful for:
- Large features
- Architecture discussions
- Early code review
- Team collaboration
31. Small Pull Requests vs Large Pull Requests
Compare:
PR #1
Payment validation
10 files
200 lines
with:
PR #2
Payment + inventory + customer + UI redesign
80 files
4,000 lines
The second Pull Request is much harder to review.
Whenever practical, keep Pull Requests focused on one logical change.
32. Pull Request Best Practices
- Keep the Pull Request focused.
- Use a descriptive title.
- Explain what changed and why.
- Include testing information.
- Mention database or configuration changes.
- Assign appropriate reviewers.
- Respond to review comments.
- Keep the branch reasonably up to date.
- Resolve conflicts before requesting final approval.
- Don't commit secrets.
- Don't include unrelated changes.
- Don't merge until required checks and approvals are complete.
33. What Should You Mention in a Laravel Pull Request?
For a Laravel project, it is useful to mention:
- New controllers
- New services
- Model changes
- Database migrations
- API changes
- Authentication/authorization changes
- Queue changes
- Scheduled jobs
- Configuration changes
- New packages
- Tests
For example:
## Summary
Added payment gateway integration.
## Laravel Changes
- PaymentService
- PaymentController
- Payment model
- Payment migration
- Payment API endpoint
## Testing
php artisan test
## Database
New payments table.
## Configuration
Added payment gateway environment variables.
## Deployment Notes
Run the payment migration during deployment.
34. Pull Request Security Review
Security should be part of code review.
Reviewers should watch for:
- Hard-coded passwords
- API keys
- Database credentials
- Unsafe user input
- Missing authorization
- Mass assignment issues
- SQL injection risks
- Insecure file uploads
- Excessive logging of sensitive information
For Laravel applications, validation, authorization, authentication, and safe database access should be reviewed carefully.
35. Pull Request Performance Review
Code review should also consider performance.
For example, a reviewer might identify:
foreach ($users as $user) {
echo $user->orders->count();
}
Depending on how the relationship is loaded, this can contribute to an N+1 query problem.
The reviewer may suggest eager loading or another query strategy:
$users = User::with('orders')->get();
The correct solution depends on the actual query and application requirements.
36. Pull Request and Database Changes
Database changes deserve special attention.
Suppose your PR adds:
database/migrations/xxxx_add_status_to_orders_table.php
The PR description should mention:
- What table changes?
- Is the migration backward compatible?
- Does existing data require migration?
- Does deployment require a specific order?
- Could the change affect production traffic?
This is especially important for large production databases.
37. Pull Request Review Checklist
Before approving a Laravel Pull Request, consider:
□ Does the feature match the requirement?
□ Is the code readable?
□ Is validation correct?
□ Is authorization handled?
□ Are database queries efficient?
□ Is there an N+1 issue?
□ Are errors handled?
□ Are tests included?
□ Do tests pass?
□ Are migrations safe?
□ Are sensitive values excluded?
□ Are there unrelated changes?
□ Is the PR description clear?
38. Developer Pull Request Checklist
Before asking for review:
□ Branch is correct
□ Changes are focused
□ No .env/secrets committed
□ git status reviewed
□ git diff reviewed
□ Tests passed
□ Commit messages are meaningful
□ PR title is clear
□ PR description is complete
□ Database changes documented
□ Configuration changes documented
□ Reviewer selected
□ Conflicts resolved
39. Complete Laravel Pull Request Example
Let's put everything together.
Step 1 — Update develop
git switch develop
git pull origin develop
Step 2 — Create feature branch
git switch -c feature/payment-gateway
Step 3 — Develop
app/Services/PaymentService.php
app/Http/Controllers/PaymentController.php
app/Models/Payment.php
Step 4 — Add migration
php artisan make:migration create_payments_table
Step 5 — Add tests
tests/Feature/PaymentTest.php
Step 6 — Run tests
php artisan test
Step 7 — Review changes
git status
git diff
Step 8 — Commit
git add .
git commit -m "feat(payment): add payment gateway"
Step 9 — Push
git push -u origin feature/payment-gateway
Step 10 — Create Pull Request
feature/payment-gateway
↓
develop
Step 11 — Code Review
Reviewers inspect the code and leave comments.
Step 12 — Fix comments
git add .
git commit -m "fix(payment): address review comments"
git push
Step 13 — Approval
Required reviewers approve the Pull Request and automated checks pass.
Step 14 — Merge
The Pull Request is merged according to the team's selected merge strategy.
40. What Happens After Merge?
After merging:
feature/payment
↓
develop
↓
Staging/Test
↓
main
↓
Production
This is only one possible workflow. Some teams use:
feature → main → production
Others use:
feature → develop → release → main
The important point is to follow the repository's documented branching and deployment strategy.
41. Should You Delete the Feature Branch?
After a Pull Request is merged, many teams delete the feature branch because it is no longer needed.
This keeps the repository clean.
However, branch retention policies differ between teams.
If you delete a local branch:
git branch -d feature/payment
The remote branch can also be removed when appropriate:
git push origin --delete feature/payment
Only delete branches according to your team's workflow.
42. Pull Request vs Direct Push
| Direct Push | Pull Request |
|---|---|
| Changes go directly to the remote branch | Changes are proposed for review first |
| Limited review before integration | Supports structured code review |
| Suitable only where repository policy permits it | Common for protected/shared branches |
| Faster for some workflows | Better suited to controlled team integration |
43. Common Pull Request Mistakes
❌ Mistake 1 — Wrong target branch
You intended:
feature/payment → develop
but accidentally selected:
feature/payment → main
Always verify the destination branch.
❌ Mistake 2 — Huge Pull Request
Avoid combining unrelated features into one PR.
❌ Mistake 3 — No tests
Always mention what you tested.
❌ Mistake 4 — Poor PR description
A reviewer should understand the purpose of the change quickly.
❌ Mistake 5 — Ignoring review comments
Respond to comments and push the required changes.
❌ Mistake 6 — Committing secrets
Never add passwords, API keys, or private credentials to source control.
❌ Mistake 7 — Merging despite failed checks
Follow the project's required quality and CI checks before merging.
44. Pull Request Best Practices for PHP Developers
- Keep one logical feature or fix per PR whenever practical.
- Use meaningful commit messages.
- Include automated tests.
- Explain database changes.
- Explain API changes.
- Check for N+1 queries.
- Review authorization and validation.
- Don't include debugging code.
- Don't commit secrets.
- Keep the PR easy to review.
45. Pull Request Best Practices for Reviewers
- Review the requirement, not only the syntax.
- Focus on correctness and maintainability.
- Check security-sensitive code carefully.
- Look for performance problems.
- Check tests.
- Ask clear and actionable questions.
- Distinguish required changes from optional suggestions.
- Don't criticize the developer personally.
- Keep discussions focused on the code and requirements.
46. Pull Request Interview Questions
Q1. What is a Pull Request?
A Pull Request is a workflow for proposing changes from one branch to another so they can be reviewed and integrated according to repository policy.
Q2. Is Pull Request a Git command?
No. A Pull Request is generally a feature of Git hosting and collaboration platforms. Git itself provides the underlying branches, commits, merges, and other operations.
Q3. What is the source branch?
The source branch contains the changes being proposed.
Q4. What is the destination branch?
The destination branch is the branch into which the changes are proposed to be integrated.
Q5. What happens after a reviewer requests changes?
The developer updates the source branch, commits the changes, and pushes them. The existing Pull Request is updated automatically.
Q6. Can you create multiple commits in one Pull Request?
Yes. A Pull Request can contain multiple commits. The team may later choose a merge strategy such as a merge commit or squash.
Q7. What happens if a Pull Request has merge conflicts?
The source branch needs to be updated and the conflicts resolved according to the team's workflow before the Pull Request can be merged.
Q8. What is code review?
Code review is the process of examining proposed changes for correctness, maintainability, security, performance, testing, and adherence to project standards.
Q9. Why should Pull Requests be small?
Smaller focused Pull Requests are generally easier to understand, review, test, and troubleshoot.
Q10. What should you include in a Pull Request description?
Include the purpose of the change, important implementation details, testing performed, database/configuration changes, and relevant deployment notes.
Q11. What is the difference between Pull Request and git pull?
A Pull Request is a collaboration/review workflow, while git pull is a local Git command that fetches and integrates remote changes.
Q12. What should you do before merging a Laravel Pull Request?
Review the code, run relevant tests, verify database/configuration changes, resolve required review comments and conflicts, and ensure required approvals and checks have passed.
47. Quick Pull Request Cheat Sheet
# Update target branch
git switch develop
git pull origin develop
# Create feature branch
git switch -c feature/payment
# Develop
# ...
# Check changes
git status
git diff
# Run tests
php artisan test
# Commit
git add .
git commit -m "feat(payment): add payment feature"
# Push
git push -u origin feature/payment
# Create Pull Request in Bitbucket
feature/payment → develop
# After review comments
git add .
git commit -m "fix(payment): address review comments"
git push
# Update branch if required
git fetch origin
git merge origin/develop
# Resolve conflicts if necessary
git status
# Run tests again
php artisan test
# Push updated branch
git push
# Merge after required approval/checks
48. Easy Way to Remember Pull Requests
CODE
↓
COMMIT
↓
PUSH
↓
PULL REQUEST
↓
REVIEW
↓
FIX
↓
APPROVE
↓
MERGE
↓
DEPLOY
The most important concept is:
A Pull Request is not just a button to merge code. It is a structured place for collaboration, review, testing, and controlled integration.
Conclusion
Bitbucket Pull Requests are a core part of professional Git development.
For a PHP or Laravel developer, you should be comfortable with the complete process:
Feature Branch
↓
Commit
↓
Push
↓
Pull Request
↓
Code Review
↓
Review Comments
↓
Tests
↓
Approval
↓
Merge
A good Pull Request should be focused, clearly described, tested, and easy for another developer to review.
If you understand this workflow, you can work effectively with Bitbucket-based PHP, Laravel, and other Git projects.
What's Next?
Now that we have covered Bitbucket Pull Requests, the next important topic is what happens when your local branch and the remote branch move in different directions.
Next Article: Git Branch Tracking & Upstream Branch Explained
We will cover:
- What is a tracking branch?
- What is an upstream branch?
- Local branch vs remote-tracking branch
git branch -vvgit push -ugit branch --set-upstream-to- Why "no upstream branch" happens
- How
git pullknows which branch to use - How
git pushknows where to push - Practical Bitbucket examples
- Common interview questions
Was this useful?
No ratings yet — yours can be the first.
Discussion
Notes from readers. Comments appear after a short review.
No comments yet. Start the thread below.