Modern Best Practices
Use these to help alleviate the above challenges (actual success depends on the culture).
Pair programming
Pair programming is basically an online code review.
Eliminates costly context-switching. Pair programmed PR is essentially already auto-approved (to the point that PRs can be automated)
Smaller commits
Short-lived branches help with achieving smaller commits.
The larger the changes the longer it takes to review and approve.
Large PR costs:
- High context switching cost to the author and reviewers because of back and forth until an agreement is reached
- Higher risk of slipping bugs due harder to understand changes
- Hurts productivity and lowers throughput
Merge directions
Rebase to bring your branch up-to-date before opening a PR.
This helps to keep your branch — about your changes (contrary to merge that mixes all together).
Keep a linear and clean history
Squash when merging PR to main for clear, clean, and easily traversable history
Releases don’t have to be branches
Release may be cut from Tag on main.
For fixing an issue in production, a release branch can be created retroactively from the Tag (and cherry-picked from main).
Cherry-pick fixes from main to release branch
This will eliminate the need to do code freezes.
No need for error-prone multi-branch merges (as in git-flow).
Will keep the history readable, clean, and clear (and auditable).
Break 1:1 feature-to-branch relationship
A feature is not a branch. If you are using Jira or similar and used to name branches after tasks, try to stop tying branch and ticket life-cycle. Many small and short-lived branches are OK.