Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 51 lines (41 sloc) 873 Bytes
#!/bin/bash
#
# Usage: like git commit, but it will provide a short list of squash-able
# commits[
#
nrefs=15
case "$1" in
--help)
echo "Usage: git squash [-n N] [git commit options]"
echo "Displays a numbered list of N recent commits."
echo ""
echo "Chosing a number will commit the staging area with"
echo "a subject line matching that commit, so that on rebase it"
echo "will be squashed in automatically."
exit 0
;;
-n)
shift
nrefs=$1
shift
;;
-n*)
nrefs=${1/-n/}
shift
;;
*)
;;
esac
declare -a ref=()
IFS='
'
refs=($(git log --format="%s" -n $nrefs))
i=0
for ref in "${refs[@]}"; do
i=$(($i + 1))
echo "[$i] $ref"
done
echo -n "Number to squash in: "
read r
ref=${refs[$r-1]}
git commit -m "fixup! $ref" $@