Skip to content

Instantly share code, notes, and snippets.

@mrexodia
Last active December 5, 2024 12:01
Show Gist options
  • Save mrexodia/5a23ab69639a6abc343ac0415958947a to your computer and use it in GitHub Desktop.
Save mrexodia/5a23ab69639a6abc343ac0415958947a to your computer and use it in GitHub Desktop.
#!/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