git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[rfc] git submodules howto

From
Miklos Vajna <vmiklos@frugalware.org>
Date
Sep 18, 2007, 10:55 UTC
Message-ID
<20070918105538.GL19019@genesis.frugalware.org>
hi,

i saw several "is there any step by step howto on how to use git submodules?" question on irc, and as far as i think there is none available at the moment

here is how i use it at the moment:
$ mkdir lib
$ cd lib
$ git init
Initialized empty Git repository in .git/
$ echo "libmakefile" > Makefile
$ dg add Makefile
$ git commit -m "libmakefile"
Created initial commit 57c1dce: libmakefile
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 Makefile
$ cd ..
$ mkdir main
$ cd main
$ git init
Initialized empty Git repository in .git/
$ echo "main makefile" > Makefile
$ git add Makefile
$ git commit -m "main makefile"
Created initial commit 8935291: main makefile
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 Makefile
$ git submodule add ../lib lib
Initialized empty Git repository in /home/vmiklos/scm/git/sub/main/lib/.git/
0 blocks
$ git commit -m "added lib submodule"
Created commit 9dbfedf: added lib submodule
 2 files changed, 4 insertions(+), 0 deletions(-)
 create mode 100644 .gitmodules
 create mode 160000 lib
$ cd ..
$ git clone main cloned
Initialized empty Git repository in /home/vmiklos/scm/git/sub/cloned/.git/
0 blocks
$ cd cloned
$ git submodule init
Submodule 'lib' (/home/vmiklos/scm/git/sub/lib/.git) registered for path 'lib'
$ git submodule update
Initialized empty Git repository in /home/vmiklos/scm/git/sub/cloned/lib/.git/
0 blocks
Submodule path 'lib': checked out '57c1dce0e083e9ee50d06111d6aa1523116c2e15'
$ cat Makefile
main makefile
$ cat lib/Makefile
libmakefile
my questions:
1) is this correct? :) i use it and it seem to do what i except, but
maybe it's not correct
2) does this worth adding to the documentation? maybe to a .txt under
Documentation/howto? or to git-submodule.txt?
thanks,
- VMiklos
Next: Johannes Schindelin
Message 1 of 28 in “[rfc] git submodules howto”
  1. Miklos VajnaSep 18, 2007
  2. Johannes SchindelinSep 18, 2007
  3. Michael SmithSep 18, 2007
  4. J. Bruce FieldsSep 18, 2007
  5. Miklos VajnaSep 18, 2007
  6. J. Bruce FieldsSep 18, 2007
  7. Miklos VajnaSep 18, 2007
  8. Michael SmithSep 18, 2007
  9. User Manual: add a chapter for submodulesMiklos Vajna, Sep 19, 2007
  10. Junio C HamanoSep 19, 2007
  11. J. Bruce FieldsSep 19, 2007
  12. User Manual: add a chapter for submodulesMiklos Vajna, Sep 20, 2007
  13. User Manual: add a chapter for submodulesMiklos Vajna, Sep 20, 2007
  14. Junio C HamanoSep 20, 2007
  15. Johannes SchindelinSep 20, 2007
  16. new test from the submodule chapter of the user manualMiklos Vajna, Sep 20, 2007
  17. Joel BeckerSep 20, 2007
  18. Johannes SchindelinSep 20, 2007
  19. Miklos VajnaSep 20, 2007
  20. Joel BeckerSep 20, 2007
  21. Junio C HamanoSep 20, 2007
  22. new test from the submodule chapter of the user manualMiklos Vajna, Sep 21, 2007
  23. Junio C HamanoSep 21, 2007
  24. new test from the submodule chapter of the user manualMiklos Vajna, Sep 22, 2007
  25. Miklos VajnaSep 20, 2007
  26. Sven VerdoolaegeSep 19, 2007
  27. Uwe Kleine-KönigSep 24, 2007
  28. Miklos VajnaSep 24, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.