Skip to main content

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:

  1. Checkout your branch.
    • git checkout <your branch>
  2. Fetch the latest changes from main.
    • git fetch
  3. Perform an interactive rebase.
    • git rebase origin/main -i
  4. squash or fixup all except for the first commit and save.

Your branch should now contain 1 commit with all changes.

  1. Run a build.
    • pnpm run build
  2. 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