-
-
Save chadwhitacre/5d2ff5f46cd0bc981b3f3b76cf891b97 to your computer and use it in GitHub Desktop.
sq - squash git commits easily
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
#!/usr/bin/env zsh | |
# | |
# https://gist.github.com/chadwhitacre/5d2ff5f46cd0bc981b3f3b76cf891b97 | |
# | |
# Squash the N most recent git commits together (default: 2), using the oldest | |
# one's commit message. | |
N=${1:-2} | |
msg="$(git log --format=%B -n 1 HEAD~$(( $N - 1 )))" | |
git reset --soft HEAD~$N && git commit -nm "$msg" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment