Squash is often preferred since features are typically cohesive units. However, if commits represent distinct logical steps (e.g., "add function," "add tests," "optimize"), rebase preserves that structure.
- Publish Branch pushes your local branch to the remote repository (GitHub) for the first time
- After publishing, continue making commits locally and push to update the remote branch
- Publishing doesn't merge into main—the branch remains separate until explicitly merged
- You can publish early to enable CI checks or collaboration while continuing development
-
Create the PR on GitHub
- Select your branch and target branch (main)
- Add description explaining changes
- Optionally request specific reviewers
-
Review Phase
- Reviewers examine code, leave comments/questions
- You respond to feedback and push additional commits as needed
- CI/automated checks run (if configured)
- Discussion continues until reviewers approve
-
Approval
- Reviewers explicitly approve the PR
- All requested changes addressed
- CI checks passing (if required)
Once approved, click "Merge pull request" with one of these options:
Pros:
- Preserves complete history with all individual commits
- Shows exactly when branch was integrated via merge commit
- Easy to revert entire feature by reverting merge commit
Cons:
- Creates non-linear history that can be cluttered with many feature branches
- Includes all "work-in-progress" commits, typo fixes, etc.
Pros:
- Clean, linear history on main—one commit per feature
- Hides messy development process (WIP commits, fixes)
- Easier to navigate
git logandgit blame
Cons:
- Loses granular commit history from development
- Individual commit metadata (timestamps, intermediate states) gone
- Makes bisecting bugs within a feature harder
Pros:
- Linear history while preserving individual commits
- Each commit appears as if developed directly on main
- Maintains logical development steps for complex features
Cons:
- Rewrites commit SHAs (breaks references if branch shared)
- Can create confusion if commits weren't meant for main individually
- More complex to revert—must revert each commit
After merging, the branch can be deleted (GitHub offers this option automatically).