Created
September 14, 2023 11:35
-
-
Save iagoalonsomrf/57a78d7b12bdfc9d7d020e5475186ba4 to your computer and use it in GitHub Desktop.
Delete your working branch after it's merged, and pull the default branch
This file contains 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 | |
DEFAULT_BRANCH="master" | |
CURRENT_BRANCH=$(git branch --show-current) | |
if git checkout "$DEFAULT_BRANCH" | |
then | |
git pull | |
if ! git branch -d "$CURRENT_BRANCH" | |
then | |
printf 'Delete anyway? (y/n)? ' | |
read -r answer | |
if [ "$answer" != "${answer#[Yy]}" ] | |
then | |
git branch -D "$CURRENT_BRANCH" | |
fi | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment