Git Submodules Cheat Sheet


ATTENTION: This page is out of date. It has not been updated since 2010, and probably will not be updated in the future.

(Pssst. Check out Your Git Submodule and You for more in-depth information.)

What you should know

Recipes

Note: the [main]$ bits on each line represents your bash prompt. You should only type the stuff after the $.


Comments



In the first recipe, shouldn't the last line be:

[main]$  git commit .gitmodules -m "Added submodule as ./subm"

And if you want to update all the submodules of a project:

$ git submodule foreach git pull origin master

Doesn't that command (foreach git pull origin master) update each submodule to master of the external submodules? That master is probably ahead of what works (or is tested) with your project.

I think this command will update each submodule in project to latest version comitted in your project: $ git submodule update --init


such a beautiful blog! I am wondering if I can use git add some files under submodule to parent repo


To get submodules automatically, you can use git clone --recursive


Comments are closed.