diff --git a/script/unstagebranch b/script/unstagebranch new file mode 100755 index 0000000..08e8b63 --- /dev/null +++ b/script/unstagebranch @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +# +# Unstage a branch + +set -e + +branch=$(git rev-parse --abbrev-ref HEAD) + +if [ -z "$1" ]; then + basebranch="master" +else + basebranch="$1" +fi + +diff=$(git diff $basebranch...HEAD) +git co -q "$basebranch" +echo "$diff" | git apply +echo "Unstaged $branch against $basebranch successfully" +git diff --shortstat "HEAD...$branch"