How do I prepare a branch for code review?
Objective: This article explains how to squash commits on a branch to prepare it for code review.
Steps:
- Checkout your branch.
git checkout <your branch>
- Fetch the latest changes from
main
.git fetch
- Perform an interactive rebase.
git rebase origin/main -i
squash
orfixup
all except for the first commit and save.
Your branch should now contain 1 commit with all changes.
- Run a build.
pnpm run build
- Force push the branch.
git push --force
Troubleshooting:
- Merge conflicts: You may run into merge conflicts during a rebase, simply resolve them and
git rebase --continue