From f4f6e9da0c54e1183867664a67065bbc71eb9f5d Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Mon, 10 Apr 2017 08:37:36 -0700 Subject: [PATCH] add git-fixup --- git-fixup | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 git-fixup diff --git a/git-fixup b/git-fixup new file mode 100755 index 0000000..90c5c37 --- /dev/null +++ b/git-fixup @@ -0,0 +1,17 @@ +#!/bin/bash +# +# From https://blog.filippo.io/git-fixup-amending-an-older-commit/ + +set -e + +function usage() { + name=$(basename "$0") + echo "Usage: ${name} [git commit arguments]" >&2 + exit 1 +} + +[[ -z "$1" ]] && usage + +target=$(git rev-parse "$1") +git commit --fixup="$target" "${@:2}" +VISUAL=true EDITOR=true git rebase -i --autostash --autosquash "$target^"