use configured remote for current branch instead of "origin"

This commit is contained in:
Sami Samhuri 2015-08-20 09:48:11 -07:00
parent d1126138f7
commit c31b5cbc01
2 changed files with 6 additions and 4 deletions

View file

@ -1,7 +1,8 @@
#!/bin/sh
REMOTE="${1:-origin}"
BRANCH="${2:-$(git rev-parse --abbrev-ref HEAD)}"
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
REMOTE="${1:-$(git config --get branch.${CURRENT_BRANCH}.remote)}"
BRANCH="${2:-$CURRENT_BRANCH}"
REPO=$(git config --get remote.${REMOTE}.url | cut -d':' -f2 | cut -d'.' -f1)
if [[ -z "$REPO" ]] || [[ -z "$BRANCH" ]]; then
echo "usage: $(basename "$0") <remote> <branch (ref)>"

View file

@ -2,8 +2,9 @@
set -e # bail on errors
REMOTE="${1:-origin}"
BRANCH="${2:-$(git rev-parse --abbrev-ref HEAD)}"
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
REMOTE="${1:-$(git config --get branch.${CURRENT_BRANCH}.remote)}"
BRANCH="${2:-$CURRENT_BRANCH}"
git update "$REMOTE" develop
git checkout develop