← Today I Learned

Update all submodules to latest commit on origin

I use Git submodules in a bunch of projects, and one common task is checking out the latest commit on the origin.

Since Git 1.8.2 this is a one-liner, but I’m always forgetting it, so here it is:

git submodule update --remote --rebase # or `--merge` if you swing that way

The answers to this StackOverflow question have some more detail (including a command that works on earlier versions of Git).