dotfiles/script/unstagebranch

20 lines
343 B
Plaintext
Raw Permalink Normal View History

2021-04-08 09:10:41 +00:00
#!/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"