A reliable Git branching and pull request workflow makes changes easier to review, test, release, and roll back. This guide compares practical branching models, provides naming conventions and reusable templates, and gives you checklists for feature work, bug fixes, hotfixes, conflicts, and repository maintenance.
Overview
Git does not impose one correct team workflow. The right approach depends on release frequency, team size, deployment automation, compliance needs, and how much parallel work a repository must support. A small team shipping continuously may need only a protected main branch and short-lived feature branches. A product with scheduled releases may benefit from explicit release branches. Long-lived branches can be useful in limited situations, but they usually increase merge distance and review complexity.
A maintainable workflow has four properties:
- Small changes: Each branch and pull request has one understandable purpose.
- Visible quality gates: Automated checks and required review happen before changes reach a shared branch.
- Predictable integration: Developers regularly update their branches and resolve conflicts before review becomes stale.
- Clear ownership: Branch names, pull request descriptions, and commit messages explain what changed and why.
Branching-model comparison
| Model | Best fit | Strength | Trade-off |
|---|---|---|---|
Feature branches from main | Teams practicing continuous integration | Simple branch structure and fast integration | Requires disciplined testing and small pull requests |
| GitHub-style flow | Web applications and frequently deployed services | Short-lived branches map directly to pull requests | Release coordination needs to be handled elsewhere |
| GitLab-style flow | Teams using merge requests and integrated CI/CD | Review, automation, and environments can follow one workflow | Teams still need explicit release and rollback conventions |
| Release branches | Scheduled releases or multiple supported versions | Stabilization can happen without stopping new development | Creates additional synchronization and backport work |
| Long-lived environment branches | Organizations with a specific operational need | Can separate deployment stages | Drift and difficult merges become more likely over time |
For many teams, a sensible default is a protected main branch, short-lived branches for individual changes, automated checks, and pull requests that merge only after review. Add release branches only when the release process genuinely requires them.
Checklist by scenario
Feature branch workflow
- Start from an up-to-date
mainbranch. - Create a branch tied to one issue, task, or clearly defined outcome.
- Use a descriptive name such as
feature/account-export,feat/account-export, orui/account-export. - Make focused commits that are easy to inspect or revert.
- Run relevant tests, linters, type checks, and local build commands.
- Push the branch and open a draft pull request if early feedback is useful.
- Update the branch with the current target branch before final approval.
- Resolve review comments, confirm checks are green, and merge using the team-approved method.
- Delete the remote branch after merging unless it serves a documented release purpose.
Bug-fix workflow
- Record the observed behavior, expected behavior, and reproduction steps.
- Create a branch such as
fix/invalid-date-filterorbugfix/cache-key-collision. - Add or update a regression test before changing implementation when practical.
- Keep the fix separate from unrelated refactoring or formatting changes.
- Describe affected versions, risk, test coverage, and rollout considerations in the pull request.
- Verify the fix against the original reproduction case and nearby edge cases.
Hotfix workflow
A hotfix should be treated as an exception to the normal pace, not an excuse to skip traceability. Branch from the commit or release line that is actually running in the affected environment. Use a name such as hotfix/payment-timeout, document the incident or issue reference, and keep the patch as narrow as possible.
- Confirm the deployed revision and target branch.
- Reproduce or clearly characterize the failure.
- Implement the smallest safe change and add a regression test where possible.
- Run focused checks first, followed by the broader suite that time and risk allow.
- Obtain the required review or emergency approval.
- Merge or deploy through the documented path.
- Apply the same fix to other active branches when needed, then verify each result separately.
Pull request template
Store a template in the repository so contributors answer the same essential questions. The following format works across common hosting platforms, although the exact menu names for enabling it may vary between GitHub, GitLab, and Bitbucket.
## Summary
- What changed?
- Why is the change needed?
## Scope
- [ ] Feature
- [ ] Bug fix
- [ ] Refactor
- [ ] Documentation
- [ ] Hotfix
## Verification
- Tests or commands run:
- Manual checks:
- Screenshots or logs, if useful:
## Risk and rollout
- User or system impact:
- Migration or configuration notes:
- Rollback plan:
## Reviewer notes
- Areas that need careful review:
- Follow-up work:Commit checklist
- Does each commit represent one coherent change?
- Does the message explain the intent rather than repeat the file name?
- Are generated files, secrets, debug logs, and unrelated local changes excluded?
- Would another developer understand the commit sequence during troubleshooting?
- Has sensitive data been removed from both the working tree and the commit history?
What to double-check
Merge versus rebase
Use a merge when preserving the full branch history or combining work without rewriting commits is more important. Merge commits can make the integration event explicit and are often a comfortable choice for shared branches.
Use rebase to update a private feature branch onto the latest target branch and create a cleaner linear sequence before review. Rebase changes commit identities, so avoid rewriting commits that other developers are actively using unless the team has agreed on the process. A practical rule is: rebase your own unpublished work; merge or coordinate carefully once a branch is shared.
Protected branches and required checks
Review the repository settings for the default and release branches. Useful controls commonly include requiring pull request review, requiring status checks, preventing direct pushes, requiring branches to be up to date before merging, and limiting who can bypass protections. Choose rules that match the repository's risk; excessive gates can encourage unsafe workarounds.
Tests and automation
At minimum, automate the checks that are reliable and relevant to every change: formatting, linting, type checking, unit tests, and a build or package validation step where applicable. Add security, integration, migration, or deployment checks when the repository needs them. Keep automation results visible in the pull request and make failures actionable. A failed check should identify the command, environment, and likely next step.
Conflict resolution
- Read both sides of the conflict before editing.
- Determine whether the correct result is one side, a combination, or a new implementation.
- Run focused tests for the affected behavior.
- Inspect the final diff rather than trusting that the conflict markers were removed.
- Ask the original author or domain owner when intent is unclear.
When a pull request contains a large conflict, pause and reassess its size. Splitting the change or restarting from a current target branch may be safer than resolving dozens of unrelated hunks at once.
Common mistakes
- Branches that live too long: Break work into smaller increments or merge safe, incomplete functionality behind an appropriate runtime control.
- Huge pull requests: Separate behavior changes, dependency updates, formatting, and refactoring when they do not need to ship together.
- Vague descriptions: Include context, expected behavior, verification, and risk. Reviewers should not have to reconstruct the ticket from the diff.
- Testing only after approval: Run fast local checks before requesting review, then rely on shared automation for consistent validation.
- Rebasing shared branches casually: Coordinate history rewrites and communicate any force-push implications.
- Mixing generated files with source edits: Explain why generated output changed and use the repository's documented generation command.
- Ignoring documentation: Update setup notes, configuration guidance, API examples, or release notes when behavior changes. A clean README and issue template can reduce review questions; see this Markdown preview and formatting guide for documentation workflow ideas.
- Assuming a green build proves everything: Automated checks are evidence, not a substitute for reviewing business logic, permissions, data changes, and user-facing behavior.
When to revisit
Review the workflow before a major planning or release cycle, after changing the hosting platform, and whenever the team adopts new CI/CD, security, deployment, or approval tooling. Revisit it after repeated merge conflicts, slow reviews, accidental direct pushes, unclear ownership, or emergency fixes that required manual steps.
Use this short maintenance checklist:
- Confirm the default branch and naming conventions still match current practice.
- Test that protected-branch rules and required checks apply to the intended branches.
- Remove obsolete CI jobs, templates, labels, and documented commands.
- Check whether pull requests are small enough to review within the team's normal working rhythm.
- Document the current merge, rebase, release, rollback, and hotfix decisions.
- Run a sample branch and pull request through the workflow when onboarding a new team or repository.
For your next change, begin with the smallest branch that can express the work, use the pull request template before coding is complete, and finish by checking the final diff, automated results, deployment impact, and rollback path. A workflow is maintainable when the repository itself makes the safe path easy to follow.