Skip to content

Instantly share code, notes, and snippets.

@darkmavis1980
Last active November 28, 2018 14:36
Show Gist options
  • Save darkmavis1980/da7dc31efe1de1005c33b25d1771c082 to your computer and use it in GitHub Desktop.
Save darkmavis1980/da7dc31efe1de1005c33b25d1771c082 to your computer and use it in GitHub Desktop.
Squash commits
// Squash the number of commits you want, 6 in this example
git reset --mixed HEAD~6
// Stage all the files
git add -A
// Commit the staged files
git commit -m "Your message"
// Then update the remote using --force
git push --force origin <YOUR-BRANCH-NAME>
// Or use rebase
git rebase -i HEAD~6
// then select the commits you want to squash by setting `s` instead of `pick`, after that save,
// and you will need to edit the commit message, and then you push force
git push --force origin <YOUR-BRANCH-NAME>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment