improve git scripts
This commit is contained in:
parent
159445cbb9
commit
065e3e9ab3
3 changed files with 9 additions and 2 deletions
|
|
@ -1,5 +1,7 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e # bail on errors
|
||||
|
||||
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
||||
REMOTE="${1:-$(git config --get branch.${CURRENT_BRANCH}.remote)}"
|
||||
BRANCH="${2:-$CURRENT_BRANCH}"
|
||||
|
|
|
|||
|
|
@ -3,7 +3,11 @@
|
|||
set -e # bail on errors
|
||||
|
||||
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
||||
REMOTE="${1:-$(git config --get branch.${CURRENT_BRANCH}.remote)}"
|
||||
DEFAULT_REMOTE=$(git config --get branch.${CURRENT_BRANCH}.remote || true) # don't fail
|
||||
if [[ -z "$DEFAULT_REMOTE" ]]; then
|
||||
DEFAULT_REMOTE=$(git config --get branch.master.remote)
|
||||
fi
|
||||
REMOTE="${1:-$DEFAULT_REMOTE}"
|
||||
BRANCH="${2:-$CURRENT_BRANCH}"
|
||||
|
||||
git update "$REMOTE" develop
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@ function current_branch() {
|
|||
}
|
||||
|
||||
ORIG_BRANCH=$(current_branch)
|
||||
REMOTE="${1:-$(git config --get branch.${ORIG_BRANCH}.remote)}"
|
||||
DEFAULT_REMOTE=$(git config --get branch.master.remote)
|
||||
REMOTE="${1:-$DEFAULT_REMOTE}"
|
||||
if [[ "$ORIG_BRANCH" = "HEAD" ]]; then
|
||||
echo "Cannot update in a detached HEAD state"
|
||||
exit 1
|
||||
|
|
|
|||
Loading…
Reference in a new issue