Add unstagebranch script

This commit is contained in:
Rob Watson 2021-04-08 11:10:41 +02:00
parent 67a6e89e56
commit 59ee22ca6a
1 changed files with 19 additions and 0 deletions

19
script/unstagebranch Executable file
View File

@ -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"