1

I have a documentation repository on github which submodules other project repositories.

I want that everytime there is a change in any projectname/docs/*, it automatically be reflected in my documentation repository's submodules. Do I have to setup a jenkins job for this (git submodule update) or does submodule do this automatically when its upstream on github?

1 Answers1

1

You will need to manually update the submodule.

The reason for this is that, internally, Git stores the specific commit of the submodule. You can see this by examining a commit using cat-file:

> git log
commit a087a65925c16f142f402ef1afe633062ad8fb2c
Author: J Doe <[email protected]>
Date:   Wed Dec 7 07:10:05 2016 -0500

    add submodule

commit 2ecbda2119ca9771a0a2ad0a8bf567aa5ce22950
Author: J Doe <[email protected]>
Date:   Wed Dec 7 07:09:58 2016 -0500

    initial commit

> git cat-file -p a087a65925c16f142f402ef1afe633062ad8fb2c
tree f34a4a6d49ff5da8042f39a9d59f6c7d6ee8e3ff
parent 2ecbda2119ca9771a0a2ad0a8bf567aa5ce22950
author J Doe <[email protected]> 1481112605 -0500
committer J Doe <[email protected]> 1481112605 -0500

add submodule

> git cat-file -p f34a4a6d49ff5da8042f39a9d59f6c7d6ee8e3ff
100644 blob 067a7e62bbe3b1f119c5e12ffb52a8896102923f    .gitmodules
160000 commit 8e7395f127fa8bd5d1370c69e7ebfd20afd6b45f  15774-a
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391    bar

There's also the .gitmodules file, which identifies the various submodules but says nothing about their current state:

[submodule "15774-a"]
    path = 15774-a
    url = file:///tmp/15774-a

This behavior makes perfect sense if you think of submodules as a tool for including a specific version of a dependency into your source tree. However, a package manager (Maven, npn, Nuget, whatever) is generally a better approach.

You can pull updates to the submodule with git submodule update

See also: https://git-scm.com/book/en/v2/Git-Tools-Submodules

kdgregory
  • 5,250