Skip to content

Squashing the commits in a Pull Request

Maxim Belkin edited this page Oct 16, 2018 · 3 revisions

If you're asked to squash (all) the commits in your Pull Request, please follow the steps below:

  1. Checkout the branch you used for submitting the original Pull Request (your-PR-branch):
git checkout your-PR-branch
  1. (Optional) Synchronize your branch with your remote if maintainers made changes to your Pull Request:
git pull your-fork your-PR-branch

If changes made by maintainers were complex, fetch your remote first and then do a hard-reset:

git fetch your-remote
git reset --hard your-remote/your-PR-branch
  1. Do a soft-reset to the beginning of the branch:
git reset --soft $(git merge-base gh-pages your-PR-branch)
  1. Create a new commit:
git commit -m "Your message"
  1. Push the changes to your fork:
git push --force your-fork