Skip to content

Instantly share code, notes, and snippets.

@JPry
Created Mar 21, 2019
Embed
What would you like to do?
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