Skip to content

Instantly share code, notes, and snippets.

@kdeloach
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kdeloach/03e0244419833365cd8c to your computer and use it in GitHub Desktop.
Save kdeloach/03e0244419833365cd8c to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
# Boilerplate template reference:
# https://github.com/oxyc/bash-boilerplate/blob/master/script.sh
sha1=""
version="0.1"
usage() {
echo -n "$(basename $0) [OPTION]... [SHA1]
Commit index then immediately squash into target SHA1.
Options:
-h, --help Display this help and exit
--version Output version information and exit
"
}
# Print help if no arguments were passed.
[[ $# -eq 0 ]] && set -- "--help"
# Read the options and set stuff
while [[ $1 = -?* ]]; do
case $1 in
-h|--help) usage >&2; exit 0 ;;
--version) echo "$version"; exit 0 ;;
*) echo "Invalid option: $1" >&2; exit 1 ;;
esac
shift
done
sha1=$1
shift
set -x
git commit --fixup $sha1
git rebase -i -p --autosquash $sha1~2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment