Git Branch & Workflow Convention
Last updated on
1. Branch meanings
develop
- Acts as the main working branch.
- All new work must start from
develop:- New feature branches (
feat/...) - Hotfix branches (
hotfix/...)
- New feature branches (
- Always up to date with the latest approved changes that are safe to integrate.
- No one commits directly to
developon remote — changes go through Pull Requests (PRs).
Example:
git checkout develop
git pull origin develop
git checkout -b feat/ticket-42_create-new-button-component
staging
- Used only for QA testing.
- Contains features that are:
- Completed by developers
- Not yet released to
main
- Rules:
- Do not create branches from
staging. - Do not merge
staginginto any other branch. - Only merge feature/hotfix branches into
stagingfor QA verification.
- Do not create branches from
Conceptually:develop = source of truth for codestaging = playground for QA to test features before release
main
- Represents production-ready code.
- Only updated via PR from
develop. - Used as the base for release tags.
Flow:develop → (PR) → main → (tag) → release
2. Development workflows
2.1 QA testing workflow
- Create a feature/hotfix branch from
develop:git checkout develop
git pull origin develop
git checkout -b feat/ticket-42_create-new-button-component - Develop freely:
git commit -m "Add base button component"
git commit -m "Add button variants and tests"- Commit as many times as needed on your feature branch.
- Push and open PR into
develop:git push origin feat/ticket-42_create-new-button-component- Open a PR:
fromfeat/ticket-42_create-new-button-component
intodevelop - Add reviewers.
- Add label:
staging(indicates this branch is ready for QA testing onstaging).
- Open a PR:
- Prepare
stagingfor QA to test this feature:- When QA needs to test:git checkout staging
git pull origin staging
git merge feat/ticket-42_create-new-button-component
# or cherry-pick specific commits if needed
# git cherry-pick <commit-hash>
git push origin staging - Resolve conflicts (if any) during the merge.
- QA tests the feature on environment deployed from
staging.
- When QA needs to test:git checkout staging
Key points:
stagingis built by merging tested feature branches into it.- PR still targets
develop;stagingis just for QA, not for code review source of truth.
2.2 Release workflow
Once QA is done and all requested changes are applied:
- Update PR status:
- Change label from
staging→ready to release.
- Change label from
- Squash commits in the feature branch into a single clean commit:
- Result: the PR into
developwill show one clean commit for this feature.git fetch -a
git checkout feat/ticket-42_create-new-button-component
git rebase -i origin/develop # squash local commits into one
git push -f origin feat/ticket-42_create-new-button-component
- Result: the PR into
- Merge into
develop:- The team lead (or responsible reviewer):
- Reviews the PR.
- Uses "Rebase and merge" for the PR into
develop.
- After the PR is merged:
- Delete the feature branch from remote.
- The team lead (or responsible reviewer):
- Prepare release from
developtomain:- Team lead creates a PR:
fromdevelop
intomain - Reviews changes if needed (final sanity check).
- Team lead creates a PR:
- Merge into
mainwith a merge commit:- Use a normal merge commit.
- Do NOT use "Rebase and merge" for
develop→main.
- Create a release tag on
main:git checkout main
git pull origin maingit tag -a v1.2.0 -m "Release v1.2.0 - button component, bug fixes"
git push origin v1.2.0- After the PR is merged:
- Create a tag on the latest
maincommit.