Nifty script to keep your local git repositories up to date

A lot of times when I try to hack on my code, I find that my git repository doesn’t have the latest commits. And in a lot of these instances I don’t have an internet connection (either because I am at a client’s location or because there is a power cut). Here is a little script which I use to keep all my local repos up to date automatically.

The git-update script should be pretty self explantory. I am looking at all the dirs under my “repos root dir” and for each of those I am finding the remotes and fetching them one at a time. The crontab entry on the other hand makes sure that every time I start my computer this script is executed. Also, I can run git update whenever I am online to get fetch all the new commits for my repos.