Skip to content

Instantly share code, notes, and snippets.

@aelindeman
Last active November 11, 2015 19:01
Show Gist options
  • Save aelindeman/93e35fe09cd98523f39a to your computer and use it in GitHub Desktop.
Save aelindeman/93e35fe09cd98523f39a to your computer and use it in GitHub Desktop.
run 'git fetch' for all repositories in a folder
#!/usr/bin/env sh
# Alex Lindeman
# 2015-11-11
# Runs 'git fetch' for all repositories in a folder.
target_folder="/srv/git"
git_opts="--prune --no-recurse-submodules"
GIT_DISCOVERY_ACROSS_FILESYSTEM=1
git_bin=$(which git)
[ $? -eq 0 ] || (echo >&2 'git not installed or not in $PATH' && exit 1)
for repo in $target_folder/*; do
if [ -d "$repo" ]; then
$git_bin fetch $git_opts -- "$repo"
fi
done
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment