Skip to content

Instantly share code, notes, and snippets.

@jelc53
Last active February 25, 2026 10:50
Show Gist options
  • Select an option

  • Save jelc53/6130fe28326b5d37ecca8019cd893b6d to your computer and use it in GitHub Desktop.

Select an option

Save jelc53/6130fe28326b5d37ecca8019cd893b6d to your computer and use it in GitHub Desktop.
step-by-step procedure for how to cleanly squash and rebase
Here's how to squash and cleanly rebase against upstream branch:
# 1. Soft reset to the merge-base (keeps your changes staged)
git reset --soft $(git merge-base main HEAD)
# 2. Commit everything as one squashed commit
git commit -m "Your squashed commit message"
# 3. Rebase onto current main
git rebase main # resolve merge conflicts once
git push --force-with-lease
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment