Skip to content

Instantly share code, notes, and snippets.

@hlucasfranca
Forked from olegchursin/commit-squashing.md
Created March 9, 2020 00:46
Show Gist options
  • Save hlucasfranca/788f995527b240f21b81e5d48c182987 to your computer and use it in GitHub Desktop.
Save hlucasfranca/788f995527b240f21b81e5d48c182987 to your computer and use it in GitHub Desktop.
Commit squashing flow
  • Make sure your branch is up to date with the master branch.
  • Run git rebase -i master.
  • You should see a list of commits, each commit starting with the word "pick".
  • Make sure the first commit says "pick" and change the rest from "pick" to "squash". -- This will squash each commit into the previous commit, which will continue until every commit is squashed into the first commit.
  • Save and close the editor (press Esc key, type :w and hit Enter key) -- save a file and quit vim / Vi by pressing Esc key, type :x and hit Enter key.
  • It will give you the opportunity to change the commit message.
  • Save and close the editor again.
  • Then you have to force push the final, squashed commit: git push --force-with-lease origin.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment