04 December 2011

Keeping git submodules up to date.

Like many others, I keep my dotfiles in a git repository, to easily track them, back them up and share them across machines. This includes my Vim configuration and add-on scripts. Even better, I use the excellent pathogen script to keep each external script in a separate git submodule. If you're not familiar with this idea, I'd suggest watching Drew Neil's excellent VimCast on how to get it set up.

I won't repeat any of that here, but what I do always seem to forget is how to update the submodules to the latest version. Remembering that git submodules are always kept in detached head state, i.e. not on any branch (which makes perfect sense from a software reliability point of view), we need to get back on the master branch before we pull in the latest changes:

$ git submodule foreach git checkout master
$ git submodule foreach git pull

Then, when you're happy that everything still works:

$ git commit -a -m "update submodules"

That's it!

Categories: All articles Git Vim