Useful git commands – part 2

Sometimes you have a project with lots of submodules that you never change yourself, but want to update occasionally. One example would be if you use Pathogen for your VIM plugins. You’d think you could use git submodule update here, and sometimes you can. But note that one of the main features of submodules is that they are locked to a particular commit. In case you want to pull in the latest changes from the remote, you need something else.

I put this alias in my .gitconfig file to solve the problem (note that this needs to be all on one line):

subup = submodule foreach 'git pull -s recursive 
-X theirs origin master'

The command will cd into each submodule, and do a forced pull overwriting any local changes you may have. Nice, right?