Created
October 1, 2020 14:30
-
-
Save siddhpant/9f1097dcb3423a497caf49951d9c9205 to your computer and use it in GitHub Desktop.
git squash alias
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[alias] | |
squash = "!f(){ git reset --soft HEAD~${1} && git commit --edit -m\"$(git log --format=%B --reverse HEAD..HEAD@{1})\"; };f" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
From https://stackoverflow.com/a/21890252
Now to squash last
X
commits usegit squash X
.For example, to squash the last 4 commits, use
git squash 4
.Note that
git squash 1
will also trigger reset due to it's working and the previous commit will be edited/overwritten with a new one, with a new hash.