Skip to content

Instantly share code, notes, and snippets.

Created Mar 21, 2019
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
# Loop through all subdirectories of the current directory that are Git repos
for gitDir in $(ls -d ./*/.git)
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment