Search code examples
gitgit-submodules

Why isn't git submodule init and git submodule update one command?


Whenever I use submodules in git find myself doing

git submodule init
git submodule update

What's the logic in two commands when you basicly do those commands every time?


Solution

  • git submodule init initializes the machinery, whereas git submodule update pulls in new changes for the submodules. If you're adding a submodule, there's nothing to update yet, so you only need to run git submodule init to initialize the repo. (It creates a .gitmodules file, as well as some stuff in .git/ for tracking submodules.)