Ad

Using `git Submodule Update`

- 1 answer

Let's say I have project_a (git repo), which contains files & another project_b (git repo).

project_a
 --> files
 --> project_b

As the git-scm book demonstrates, I can run:

cd project_a
git submodule init
git submodule update // clones project_b repo specified in '.gitsubmodules'

to populate the initially empty project_b directory within project_a.

Rather than run git submodule update to get the latest from project_b, I'd prefer to clone the latest version of project_b at a point in time, and then have project_a only use that version (unless, of course, I do a git pull in project_b).

How can I do this?

Ad

Answer

What you're describing is exactly how submodules already work in git. If you don't update the hash for the submodule and check it in to project_a, you'll always use the same revision of project_b.

Ad
source: stackoverflow.com
Ad