Skip to content

Instantly share code, notes, and snippets.

@JPry
Created March 21, 2019 13:54
Show Gist options
  • Save JPry/03a8f9fedfb7ea56590583aed050cbef to your computer and use it in GitHub Desktop.
Save JPry/03a8f9fedfb7ea56590583aed050cbef to your computer and use it in GitHub Desktop.
Look for any git repos in the current directory, and run `hub sync` in each one.
#!/usr/bin/env bash
set -e
# Ensure we have the `hub` command available.
if ! [[ -x "$(command -v hub)" ]]; then
echo "Error: 'hub' is required"
exit 1
fi
# Loop through all subdirectories of the current directory that are Git repos
for gitDir in $(ls -d ./*/.git)
do
parent=$(echo ${gitDir} | sed -E 's/\/.git\/?//')
echo "running hub sync: hub --git-dir='${gitDir}' --work-tree='${parent}' sync"
hub --git-dir="${gitDir}" --work-tree="${parent}" sync
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment