Last updated 2026-11-27
Create a branch for each change
Start every new feature, fix or experiment on its own branch created from the main branch. A short descriptive name, such as feature/login-validation or fix/invoice-rounding, makes the purpose clear. Keep branches focused on one change, because small branches are easier to review and less likely to conflict.
Commit clearly and often
Make small commits with messages that explain what changed and why. Commit when a logical step works, rather than once at the end of a long session. Clear history helps reviewers and makes it easier to revert a single change if something goes wrong later.
Keep branches up to date
Regularly bring the latest main branch into your feature branch, either by merging it or rebasing, depending on your team's rules. Resolve conflicts early while the changes are fresh in your mind. Long-lived branches that drift far from main usually produce the hardest merges.
Review and merge through pull requests
Open a pull request with a summary, the testing you did and any screenshots for interface changes. Ask at least one colleague to review it, and address comments in new commits. Once approved and passing automated checks, merge the branch and delete it to keep the repository tidy.
Frequently asked questions
- Should I merge or rebase?
- Choose the approach your team has agreed on. Merging keeps the full history, while rebasing creates a cleaner linear history. Avoid rebasing branches that other people are already using.
- How long should a branch live?
- Ideally a few days. Break large work into smaller branches so changes can be reviewed and merged frequently.
- What if I accidentally commit to main?
- Create a branch from the current state, then reset main to match the remote branch if your team's policy allows. Ask a colleague if you are unsure, especially on a shared repository.