Last active
October 1, 2021 14:06
-
-
Save RyanSiu1995/da44646f747623d9f51ec52724f16066 to your computer and use it in GitHub Desktop.
Sync the local branches with origin remote
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
#!/bin/bash -e | |
git fetch origin -p | |
REMOTE=$(git branch -r | sed "s/origin\///g") | |
BRANCHES=$(git branch | awk -F ' +' '! /\(no branch\)/ {print $2}') | |
for branch in $BRANCHES; do | |
if [[ -z $(echo $REMOTE | grep -w $branch) ]]; then | |
git branch -D $branch | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment