Created
September 8, 2021 06:44
-
-
Save svagionitis/eb00df57e6d521a90deeae0bd48b82a8 to your computer and use it in GitHub Desktop.
Git fetch git repos in directories recursively
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh -eu | |
# Git fetch git repos in directories recursively | |
usage() | |
{ | |
echo "Usage: $0 <directory>" | |
} | |
if [ -z "${1}" ]; then | |
usage | |
exit 1 | |
fi | |
INPUT_DIR=${1} | |
# See https://stackoverflow.com/questions/11981716/how-to-quickly-find-all-git-repos-under-a-directory | |
GIT_REPOS_DIR=$(find "${INPUT_DIR}" -type d -execdir test -d {}/.git \; -prune -print) | |
for dir in ${GIT_REPOS_DIR}; do | |
cd "${dir}" | |
echo "Updating git repo in ${dir}" | |
git fetch --all | |
cd - | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment