A bash script would probably be easiest to write and pluck into cron.
Edit: Clone all repos you want into one directory and then loop with a script over all cloned dirs and issue git fetch. Done. If you want to add a repo you clone another.
A bash script would probably be easiest to write and pluck into cron.
Edit: Clone all repos you want into one directory and then loop with a script over all cloned dirs and issue git fetch. Done. If you want to add a repo you clone another.
Hey, that's almost what I made Gire for. It doesn't support completely anonymous reads though (requires SSH keys for auth).
Assuming you have all of them under a folder, I just run this lol
for f in *; do
echo "$f";
git -C "$f" pull;
git -C "$f" submodule update --recursive --remote;
echo "";
echo "#########################################################################";
echo "";
done
Bash and a dedicated user should work with very little effort. Basically, create a user on your VM (maybe called git), set up passwordless (and keyless) ssh for this user but force the command to be the git-shell. Next a simple bash script which iterates directories in this user’s home directory and runs git fetch —all. Set cron to run this script periodically (every hour?). To add a new repository, just ssh as your regular user and su to the git user, then clone the new repository into the home directory. To change the upstream, do the same but simply update the remote.
This could probably be packaged as a dockerfile pretty easily, if you don’t mind either needing to specify the port, or losing the machine’s port 22.
EDIT: I found this after posting, might be the easiest way to serve the repositories, in combination with the update script. There’s a bunch more info in the Git Book too, the next section covers setting up HTTP…
git is already a decentralized version control software. Your local git repos are mirrors by themselves.
Put some git fetch in a server crontab, and you're done. You can access them via ssh if your user have permissions.
I'd personally do what others are suggesting and use bash, but you could also go with http://myrepos.branchable.com/
I'd look into the git-maintenance's prefetch task. From what I understand, that is more or less what you are looking for. Then just run any old http(s) server and clone them from that https://git-scm.com/docs/git-maintenance
all 14 comments