Last active
December 5, 2024 12:01
-
-
Save mrexodia/5a23ab69639a6abc343ac0415958947a to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
FEATURE=$(git branch --show-current) | |
if git show-ref --quiet refs/remotes/origin/main; then | |
MAIN=main | |
elif git show-ref --quiet refs/remotes/origin/master; then | |
MAIN=master | |
else | |
echo "No main branch found" >&2 | |
exit 1 | |
fi | |
if [ "$MAIN" = "$FEATURE" ]; then | |
echo "Already on $MAIN" >&2 | |
exit 0 | |
fi | |
git fetch origin --prune | |
git checkout $MAIN | |
git pull | |
git branch --delete $FEATURE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment