Skip to content

Instantly share code, notes, and snippets.

@ojacques
Created July 22, 2021 11:45
Show Gist options
  • Save ojacques/27720c4730deec230a6a684fbda3563f to your computer and use it in GitHub Desktop.
Save ojacques/27720c4730deec230a6a684fbda3563f to your computer and use it in GitHub Desktop.
GIT: Squash commits inside a PR, before even merging

When you have a PR which has been here for some times, and master is very active, you will end up have lots of commits in your history when you get the changes from master.

To clean this up:

  • git fetch origin: get the latest from the repo
  • git checkout my_branch: go to your branch for pull request
  • git rebase origin/master: this will rebase the current branch with master
  • git push -f: force push, as we are rewriting history
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment