Commit e1a5a2cc authored by Jeremy Soller's avatar Jeremy Soller

Improve fetch git branch logic

parent a27a6415
......@@ -119,14 +119,17 @@ function op {
git remote add upstream "$GIT_UPSTREAM"
git fetch upstream
fi
ORIGIN_BRANCH="$(git branch --remotes | grep '^ origin/HEAD -> ' | cut -d ' ' -f 5-)"
if [ -n "$BRANCH" ]
then
git checkout "$BRANCH"
else
#TODO: Find correct upstream default branch
git checkout master
ORIGIN_BRANCH="origin/$BRANCH"
fi
if [ "$(git rev-parse HEAD)" != "$(git rev-parse $ORIGIN_BRANCH)" ]
then
git checkout -B "$(echo "$ORIGIN_BRANCH" | cut -d / -f 2-)" "$ORIGIN_BRANCH"
fi
git pull
git submodule sync --recursive
git submodule update --init --recursive
popd > /dev/null
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment