Last active
April 7, 2021 17:05
-
-
Save jotaelesalinas/a1f7a3c3477c5805411c7f739e29d50c to your computer and use it in GitHub Desktop.
Easy git-squash (merges last N commits in one)
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
@echo off | |
if "%1"=="" goto blank | |
echo Squashing %1 commits... | |
git reset --soft HEAD~%1 | |
git log --format=%%B%%n --reverse "HEAD@{1}" -n %1 > _msg.txt | |
git commit -t _msg.txt | |
del _msg.txt | |
echo Done! | |
goto end | |
:blank | |
echo Missing parameter: number of commits to squash. | |
exit /B 1 | |
:end |
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/bash | |
if [ $# -ne 1 ]; then | |
echo "Missing parameter: number of commits to squash." | |
exit 1 | |
fi | |
echo "Squashing $1 commits..." | |
git reset --soft HEAD~$1 | |
git log --format=%B%n --reverse "HEAD@{1}" -n $1 > _msg.txt | |
git commit -t _msg.txt | |
rm _msg.txt | |
echo "Done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
True. You become the owner of all the squashed changes.