Created
June 8, 2023 16:43
-
-
Save radavis/ef3f71d7724027496eb5a1d861ef7669 to your computer and use it in GitHub Desktop.
Keep a list of repositories up-to-date, locally.
This file contains hidden or 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
#!/usr/bin/env bash | |
set -Eeuo pipefail | |
# bin/fetch - Fetch or clone repositories from $(pwd)/Reposfile. Useful | |
# for keeping a list of repositories up-to-date. | |
# usage: ./bin/fetch [--verbose] | |
repos="$(pwd)/Reposfile" | |
flags="$*" | |
[ -z "$flags" ] && flags="--quiet" | |
while read repo; do | |
filename="${repo##*/}" | |
foldername="${filename%%.*}" | |
if [ ! -d "$foldername" ]; then | |
echo "Cloning $repo" | |
git clone "$flags" "$repo" | |
else | |
git -C "$foldername" fetch "$flags" | |
fi | |
done < "$repos" |
This file contains hidden or 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
[email protected]:username/reponame.git | |
[email protected]:username/another-repo.git |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you simply want to clone a list of repositories in a Reposfile:
<Reposfile xargs -I % git clone %