Last active
December 1, 2017 16:54
-
-
Save randomecho/59873654428bc4e07566e913b59ea058 to your computer and use it in GitHub Desktop.
Merge and then delete traces of feature branch
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/sh | |
feature_branch=$(git branch | grep \* | sed 's/\* //') | |
all_branches=$(git branch | tr '\n' ' ') | |
main_branch=$1 | |
if [[ $all_branches != *$main_branch* ]]; then | |
echo "$main_branch is not a valid branch to merge back into" | |
exit 1 | |
fi | |
exit | |
if [ $# -ne 1 ]; then | |
echo "missing main branch to merge back into" | |
exit 1 | |
fi | |
if [ $feature_branch == $main_branch ]; then | |
echo "cannot merge branch into itself" | |
exit 1 | |
fi | |
git checkout $main_branch | |
git pull | |
git merge $feature_branch | |
git push origin $main_branch | |
git push origin --delete $feature_branch | |
git branch -D $feature_branch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment