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 | |
# script to interactively git rebase commits that have a single character '.' as the commit message | |
# onto the first commit that isn't just a '.' | |
squashLine=$(git log --oneline | grep -n -m 1 --perl-regexp "^[\da-f]*\s[^.]") | |
lineNumber=$(echo ${squashLine} | cut -d : -f 1) | |
if (( lineNumber >= 2 )); then | |
squashTo=$(echo ${squashLine} | cut -d : -f 2) | |
echo "Squish ${lineNumber} commits onto ${squashTo}" | |
GIT_SEQUENCE_EDITOR="sed -i -re 's/^pick ([0-9a-f]*) \.$/f \1 ./'" git rebase -i HEAD~${lineNumber} | |
echo "FYI, top 2 HEAD commits now ..." |