Git submodule

So far, I didn't have opportunity to use Git submodule. In 2011, I have one and will have another.

Use of Git submodule (case 1)

The site www.gniibe.org runs on CherryPy and I maintain its CherryPy application named Unguent with Git. As written in Git for website, I use Git to maintain the contents, too.

That' is, the site equals to algorithm plus data, where algorithm is Unguent and data is the contents.

In this situation, I thought that it makes sense to put contents in the main Git repository of web site, and put Unguent as a sumodule of main.

Suppose I have done Initial settings of Git on new machine. Then I do following to have www.gniibe.org working copy.

$ cd work
$ git clone ssh://www.gniibe.org/home/gniibe/git/www.gniibe.org.git
Initialized empty Git repository in /home/gniibe/work/www.gniibe.org/.git/
remote: Counting objects: 257, done.
remote: Compressing objects: 100% (234/234), done.
remote: Total 257 (delta 103), reused 0 (delta 0)
$ cd www.gniibe.org
$ git submodule init
Submodule 'unguent' (ssh://www.gniibe.org/home/gniibe/git/unguent.git) registered for path 'unguent'
$ git submodule update
Initialized empty Git repository in /home/gniibe/work/www.gniibe.org/unguent/.git/
remote: Counting objects: 109, done.
remote: Compressing objects: 100% (103/103), done.
remote: Total 109 (delta 60), reused 0 (delta 0)
Receiving objects: 100% (109/109), 15.09 KiB, done.
Resolving deltas: 100% (60/60), done.
Submodule path 'unguent': checked out '4d3b5b2d4290f95f8a1e9ba3466629e763e91d4d'

Note that I maintain the site content together with Unguent. I do following to track master branch of Unguent, because Git detachs its HEAD.

$ cd unguent
$ git branch
* (no branch)
  master
$ git checkout master
Switched to branch 'master'
$

Use of Git submodule (case 2)

Gnuk uses ChibiOS/RT for the kernel. Currently, it just have a copy of ChibiOS/RT, but I am thinking it would be better to use submodule.

No, not yet.

Further Readings

See Git Submodule Tutorial and Git community book for more.