add git-update
This commit is contained in:
parent
f9838ca8a0
commit
d2c156ee34
1 changed files with 14 additions and 0 deletions
14
git-update
Executable file
14
git-update
Executable file
|
|
@ -0,0 +1,14 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
BRANCH=$(git branch --no-color --list | grep '^\*' | awk '{print $2}')
|
||||||
|
if [[ "$BRANCH" != "(detached" ]]; then
|
||||||
|
STASH_OUTPUT=$(git stash)
|
||||||
|
if [[ "$STASH_OUTPUT" = "No local changes to save" ]]; then
|
||||||
|
POP_STASH=0
|
||||||
|
else
|
||||||
|
POP_STASH=1
|
||||||
|
fi
|
||||||
|
git fetch --prune --tags origin && git rebase "origin/$BRANCH" && ([[ $POP_STASH -eq 1 ]] && git stash pop) || true
|
||||||
|
else
|
||||||
|
echo "Cannot update in a detached HEAD state"
|
||||||
|
fi
|
||||||
Loading…
Reference in a new issue