User Tools

Site Tools


git_submodules

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
git_submodules [2019/02/27 14:34]
rpjday [The end result]
git_submodules [2019/02/27 19:14]
rpjday [Overview]
Line 3: Line 3:
 The good and the bad of submodules, using Wind River'​s Pulsar Linux as a convenient example. The good and the bad of submodules, using Wind River'​s Pulsar Linux as a convenient example.
  
 +Stuff to add:
 +
 +  * ''​git config submodule.<​what>​.url PRIVATE_URL''​
 ===== Links ===== ===== Links =====
  
Line 331: Line 334:
 </​code>​ </​code>​
  
-==== The end result ​====+Note that this has //not// committed the new submodule yet. So what //has// it done? 
 + 
 +==== The situation thus far ====
  
 <​code>​ <​code>​
Line 362: Line 367:
 </​code>​ </​code>​
  
- +The content of the new submodule working tree:
-==== Adding a submodule -- what just happened? ==== +
- +
-=== The new .gitmodules file === +
- +
-The new ''​.gitmodules''​ file, which is version-controlled just like your other files so other developers can get the submodules when they clone the "​superproject"​:+
  
 <​code>​ <​code>​
-[submodule "coroutine2"] +$ tree coroutine2/ 
- path = coroutine2 +coroutine2/ 
- url = https://github.com/​boostorg/​coroutine2+├── doc 
 +│   ├── acknowledgements.qbk 
 +│   ├── architectures.qbk 
 +│   ├── asymmetric.qbk 
 +│   ├── coro.qbk 
 +│   ├── coroutine.qbk 
 +│   ├── images 
 +│   │   ├── event_model.dia 
 +│   │   ├── event_model.png 
 +... etc etc ...
 </​code>​ </​code>​
  
-=== git diff === +The content of the new submodule's Git directory:
- +
-There is no current ''​git diff''​ since adding ​the submodule ​has already been staged:+
  
 <​code>​ <​code>​
-$ git diff+ls -lF .git/​modules/​coroutine2/​ 
 +total 48 
 +drwxrwxr-x. 2 rpjday rpjday 4096 Feb 27 09:31 branches/ 
 +-rw-rw-r--. 1 rpjday rpjday ​ 297 Feb 27 09:31 config 
 +-rw-rw-r--. 1 rpjday rpjday ​  73 Feb 27 09:31 description 
 +-rw-rw-r--. 1 rpjday rpjday ​  24 Feb 27 09:31 HEAD 
 +drwxrwxr-x. 2 rpjday rpjday 4096 Feb 27 09:31 hooks/ 
 +-rw-rw-r--. 1 rpjday rpjday 7299 Feb 27 09:33 index 
 +drwxrwxr-x. 2 rpjday rpjday 4096 Feb 27 09:31 info/ 
 +drwxrwxr-x. 3 rpjday rpjday 4096 Feb 27 09:31 logs/ 
 +drwxrwxr-x. 4 rpjday rpjday 4096 Feb 27 09:31 objects/ 
 +-rw-rw-r--. 1 rpjday rpjday 1161 Feb 27 09:31 packed-refs 
 +drwxrwxr-x. 5 rpjday rpjday 4096 Feb 27 09:31 refs/
 $ $
 </​code>​ </​code>​
  
-but examine what's been staged:+==== Running "git diff" ====
  
 <​code>​ <​code>​
-$ git diff --staged+$ git diff --cached
 diff --git a/​.gitmodules b/​.gitmodules diff --git a/​.gitmodules b/​.gitmodules
 new file mode 100644 new file mode 100644
Line 399: Line 418:
 diff --git a/​coroutine2 b/​coroutine2 diff --git a/​coroutine2 b/​coroutine2
 new file mode 160000 new file mode 160000
-index 0000000..fc3cb67+index 0000000..0233d35
 --- /dev/null --- /dev/null
 +++ b/​coroutine2 +++ b/​coroutine2
 @@ -0,0 +1 @@ @@ -0,0 +1 @@
-+Subproject commit ​fc3cb675279708a48eb31ad2d53461b0ed4c5540++Subproject commit ​0233d35081de5b669c60ef8ec5a53854e1b2a577
 $ $
 </​code>​ </​code>​
  
-You can also use the ''​%%--%%submodule''​ option:+Abbreviated form:
  
 <​code>​ <​code>​
Line 420: Line 439:
 +       path = coroutine2 +       path = coroutine2
 +       url = https://​github.com/​boostorg/​coroutine2 +       url = https://​github.com/​boostorg/​coroutine2
-Submodule coroutine2 0000000...fc3cb67 ​(new submodule)+Submodule coroutine2 0000000...0233d35 ​(new submodule)
 $ $
 </​code>​ </​code>​
Line 427: Line 446:
  
 <​code>​ <​code>​
-$ git commit -am "added coroutine2 submodule"​ +$ git commit -a -m "added coroutine2 submodule"​ 
-[master ​bec4c94] added coroutine2 submodule+[master ​a7561cb] added coroutine2 submodule
  2 files changed, 4 insertions(+)  2 files changed, 4 insertions(+)
  ​create mode 100644 .gitmodules  ​create mode 100644 .gitmodules
- ​create mode 160000 coroutine2 ​    ​<-- weird mode for submodule+ ​create mode 160000 coroutine2 ​   <--- weird mode representing ​submodule
 $ $
 </​code>​ </​code>​
Line 439: Line 458:
 <​code>​ <​code>​
 $ git push origin master $ git push origin master
-</​code>​ 
- 
-===== Under the hood ===== 
- 
-The submodule directory has a //file// named ''​.git'',​ not a //​directory//,​ which refers to submodule information in the superproject:​ 
- 
-<​code>​ 
-$ cat coroutine2/​.git 
-gitdir: ../​.git/​modules/​coroutine2 
-$ 
-</​code>​ 
- 
-From the superproject,​ you can see the information for each submodule: 
- 
-<​code>​ 
-$ ls -l .git/​modules/​coroutine2/​ 
-total 48 
-drwxrwxr-x. 2 rpjday rpjday 4096 Feb 13 15:37 branches 
--rw-rw-r--. 1 rpjday rpjday ​ 297 Feb 13 15:37 config 
--rw-rw-r--. 1 rpjday rpjday ​  73 Feb 13 15:37 description 
--rw-rw-r--. 1 rpjday rpjday ​  24 Feb 13 15:37 HEAD 
-drwxrwxr-x. 2 rpjday rpjday 4096 Feb 13 15:37 hooks 
--rw-rw-r--. 1 rpjday rpjday 7299 Feb 13 15:38 index 
-drwxrwxr-x. 2 rpjday rpjday 4096 Feb 13 15:37 info 
-drwxrwxr-x. 3 rpjday rpjday 4096 Feb 13 15:37 logs 
-drwxrwxr-x. 4 rpjday rpjday 4096 Feb 13 15:37 objects 
--rw-rw-r--. 1 rpjday rpjday 1174 Feb 13 15:37 packed-refs 
-drwxrwxr-x. 5 rpjday rpjday 4096 Feb 13 15:37 refs 
-$ 
-</​code>​ 
- 
-===== Cloning a project with submodules ===== 
- 
-If you don't want to populate the submodule directories:​ 
- 
-<​code>​ 
-$ git clone https://​github.com/​boostorg/​boost 
-</​code>​ 
- 
-If you want to populate the submodule diredctories:​ 
- 
-<​code>​ 
-$ git clone --recurse-submodules https://​github.com/​boostorg/​boost 
-</​code>​ 
- 
-Populate all submodules after the fact: 
- 
-<​code>​ 
-$ git submodule update --init --recursive 
 </​code>​ </​code>​
  
  
git_submodules.txt · Last modified: 2019/02/27 19:14 by rpjday