Quick tip for updating git repos

 

If you're like me and you keep all your git repositories in a single directory, I assert you're also like me and don't update them from time to time. Now, I'm not particularly an advocate for just willy-nilly updating all of your git repos just because you want to, but sometimes it just makes sense (like if you're about to head up on an airplane and need to update a few repos before you take off). Well, I had a little bash fun and came up with this little line.

find . -type d -maxdepth 1 \
    -exec bash -c "cd '{}' && if [ -d \$PWD'/.git' ]; then \
    echo 'updating ' \$PWD; git pull origin master 2>/dev/null; fi" \;

Basically this looks through the current directory for all the files and directories. If there is a .git directory then it will pull the latest and greatest version (presumably from github). That's it. Hope this helps someone else.