Skip to content

Commit

Permalink
Merge pull request #793 from unixorn/tweak-upstream-sync
Browse files Browse the repository at this point in the history
Improve default remote detection
  • Loading branch information
unixorn authored Nov 19, 2024
2 parents 9e2d405 + aa4531d commit d38a6ae
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions bin/git-upstream-sync
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@

branch_name=$(git symbolic-ref --short -q HEAD)
upstream_remote=$(git config --get upstream-sync.remote)

# shellcheck disable=SC2181
if [[ $? != 0 ]]; then
echo 'Using default remote of upstream'
upstream_remote='upstream'
if [[ -n "$upstream_remote" ]]; then
upstream_remote=$(git remote show | head -1)
fi
fi

git fetch "${upstream_remote}" && \
git fetch "${upstream_remote}" -p && \
git rebase "${upstream_remote}/${branch_name}" && \
git push && \
git fetch -p
git push

0 comments on commit d38a6ae

Please sign in to comment.