Skip to content

Instantly share code, notes, and snippets.

@nibble-4bits
Last active August 12, 2020 16:20
Show Gist options
  • Save nibble-4bits/2060b83c119aacd3ab1d4137920e1e81 to your computer and use it in GitHub Desktop.
Save nibble-4bits/2060b83c119aacd3ab1d4137920e1e81 to your computer and use it in GitHub Desktop.
A bash script to pull all outdated git branches
#!/bin/bash
git fetch > /dev/null
CURRENT_BRANCH=$(git branch --show-current)
OUTDATED_BRANCHES=$(git branch -v | grep 'behind' | tr -d '*' | awk '{ print $1 }')
for BRANCH in $OUTDATED_BRANCHES
do
git checkout "$BRANCH" | head -1
git pull
echo
done
git checkout "$CURRENT_BRANCH"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment