Created
May 5, 2020 11:37
-
-
Save lcpriest/77ee492790d33f9c5722658d67a564d6 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
# git-auto-rebase | |
# git-auto-rebase --force-push | |
function git-auto-rebase() { | |
target="master" | |
if [[ $@ = "--force-push" ]] | |
then | |
push=true | |
else | |
push=false | |
fi | |
git for-each-ref --format="%(refname:short)" refs/heads | \ | |
while read branch | |
do | |
git checkout $branch &> /dev/null | |
git rebase $target &> /dev/null | |
if [ "$?" = 0 ] | |
then | |
COLOR="\033[0;32m✔" | |
message="successfully rebased" | |
if [ "$push" = true ] | |
then | |
git push origin $branch --force | |
fi | |
else | |
git rebase --abort | |
COLOR="\033[0;31m✘" | |
message="failed to rebase, skipping" | |
fi | |
printf "$COLOR %-40s | %s\n" $branch $message | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment