Created
June 19, 2017 08:06
-
-
Save wancw/833c243bcfc04fe80e76bc833145c99a to your computer and use it in GitHub Desktop.
Update all tracking Git branches
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 zsh | |
ORIG_BRANCH="$(git rev-parse --abbrev-ref HEAD)" | |
if [[ "$ORIG_BRANCH" == "HEAD" ]] { | |
ORIG_BRANCH="$(git rev-parse --short HEAD)" | |
} | |
for b in $(git branch --track | grep -v 'detached' | sed 's/*//') | |
do | |
git checkout "${b}" | |
git rev-parse --abbrev-ref @{u} && git merge --ff-only | |
echo | |
done | |
LAST_BRANCH="$(git rev-parse --abbrev-ref HEAD)" | |
if [[ "$ORIG_BRANCH" != "$LAST_BRANCH" ]] { | |
git checkout --quiet "$ORIG_BRANCH" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment