Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I make a Git repo automatically update from a remote when I try to fetch from it?

Tags:

git

I would like to set up a Git repository on my local network as a mirror of another repository, only reachable over a slow WAN. The idea is that the local (bare) repo would serve as a cache, so new commits would only have to be pulled across the WAN once.

Is there a way to configure that intermediate repo (via hooks, etc.) to automatically fetch from its configured remote if a client tries to fetch from the intermediate repo? I'm trying to find a way to ensure that the clients always see the most up-to-date commits if they fetch.

I realize I could approximate this using a script called periodically via cron, but that introduces the possibility of missing very recent commits. I'm hoping to set up something more automatic if possible.

like image 468
Jason R Avatar asked Dec 31 '25 06:12

Jason R


1 Answers

From my initial searches, there doesn't seem to be a "built-in" way to do this with Git alone, but I did find gitpod, a set of scripts that do what I want. I have it installed on my intermediate server, configured appropriately to fetch from the authoritative remote servers. I then have my clients configured to pull from the proxy server using the git:// protocol. It all seems to be working well.

like image 101
Jason R Avatar answered Jan 01 '26 23:01

Jason R



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!