Created
May 1, 2018 00:05
-
-
Save amgohan/ab95c608d0dfc83ac531a84866632993 to your computer and use it in GitHub Desktop.
Squash the last 'n' commits
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
#!/bin/sh | |
# usage : squash 3 "new comment to replace the 3 last commits" | |
active_branch=$(git branch | head -n 1) | |
branch_name=${active_branch:2} | |
commits_to_squash=$1 | |
new_commit_message=$2 | |
git reset --soft HEAD~${commits_to_squash} | |
git commit -am "${new_commit_message}" | |
git push origin +${branch_name} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment