Last active
July 13, 2020 10:07
-
-
Save bencord0/1df8ab8e3fce0a56c54d986248ac6e76 to your computer and use it in GitHub Desktop.
Rebase all local branches and scrub those that are already merged.
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 | |
set -e | |
git detach origin/master | |
set +e | |
mapfile -t BRANCHES < <(git branch | grep -v -e '\*' -e '\+') | |
for branch in "${BRANCHES[@]}"; do | |
branch_name="$(echo "$branch"|awk '{print $1}')" | |
echo "=== $branch_name ===" | |
git switch "${branch_name}" | |
git rebase origin/master || git rebase --abort | |
git detach origin/master | |
git branch -d "${branch_name}" | |
done |
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 | |
mapfile -t BRANCHES < <(git branch | grep -v -e '\*' -e '\+') | |
for branch in "${BRANCHES[@]}"; do | |
echo "Pushing local branch: ${branch}" | |
git switch "${branch}" | |
git push origin +HEAD | |
done | |
git switch --detach origin/master |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment