Git Repo Management - submodules

I have a bunch of git repos within repos and keeping them all up to date can be a pain. I was digging around the interweb and put together a one-liner to get all repos within your directory tree up to date.


find . -maxdepth 3 -name .git -type d | rev | cut -c 6- | rev | xargs -I {} git -C {} pull


We set a max depth of 3 folders deep and find all of the git repos; from there pull each.


Extension : make your life a little easier


add the following to your .bash_profile:


alias git-pull-all="find . -maxdepth 3 -name .git -type d | rev | cut -c 6- | rev | xargs -I {} git -C {} pull" 

when you want to update just run:


git-pull-all

This worked for me on a Mac but I have setup all keys in my github repo to streamline things. To keep you packages up to date you'll need to work a little more with git.

0 views0 comments