Created
June 5, 2023 13:38
-
-
Save shaunmolloy/a1eb19898a544e05eca7c4e274166d65 to your computer and use it in GitHub Desktop.
upstream-merge - merge in changes from upstream
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Checkout to upstream-merge branch if we're not on one | |
BRANCH="$(git branch --show-current)" | |
if [[ ! "$BRANCH" =~ "upstream-merge" ]]; then | |
git checkout -b feature/upstream-merge | |
fi | |
# Fetch latest from upstream | |
git fetch upstream | |
# Detect if upstream has a main or master branch and merge in | |
if [ "$(git show-ref remotes/upstream/main)" ]; then | |
git merge remotes/upstream/main | |
elif [ "$(git show-ref remotes/upstream/master)" ]; then | |
git merge remotes/upstream/master | |
else | |
echo "Exiting: upstream has no main or master branch" | |
exit 1 | |
fi | |
# Push to origin | |
git push -u origin $(git branch --show-current) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment