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:37]
rpjday [Adding a submodule -- what just happened?]
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 382: Line 387:
  
 <​code>​ <​code>​
-tree .git/​modules/​coroutine2/​ +ls -lF .git/​modules/​coroutine2/​ 
-.git/​modules/​coroutine2/​ +total 48 
-├── branches +drwxrwxr-x2 rpjday rpjday 4096 Feb 27 09:31 branches/ 
-├── config +-rw-rw-r--. 1 rpjday rpjday ​ 297 Feb 27 09:31 config 
-├── description +-rw-rw-r--1 rpjday rpjday ​  73 Feb 27 09:31 description 
-├── HEAD +-rw-rw-r--1 rpjday rpjday ​  24 Feb 27 09:31 HEAD 
-├── hooks +drwxrwxr-x2 rpjday rpjday 4096 Feb 27 09:31 hooks/ 
-│   ├── applypatch-msg.sample +-rw-rw-r--. 1 rpjday rpjday 7299 Feb 27 09:33 index 
-│   ├── commit-msg.sample +drwxrwxr-x2 rpjday rpjday 4096 Feb 27 09:31 info/ 
-│   ├── fsmonitor-watchman.sample +drwxrwxr-x3 rpjday rpjday 4096 Feb 27 09:31 logs/ 
-│   ├── post-update.sample +drwxrwxr-x. 4 rpjday rpjday 4096 Feb 27 09:31 objects/ 
-│   ├── pre-applypatch.sample +-rw-rw-r--. 1 rpjday rpjday 1161 Feb 27 09:31 packed-refs 
-│   ├── pre-commit.sample +drwxrwxr-x. 5 rpjday rpjday 4096 Feb 27 09:31 refs/
-│   ├── prepare-commit-msg.sample +
-│   ├── pre-push.sample +
-│   ├── pre-rebase.sample +
-│   ├── pre-receive.sample +
-│   └── update.sample +
-├── index +
-├── info +
-│   └── exclude +
-├── ​logs +
-│   ├── HEAD +
-│   └── refs +
-│   ​    ​├── heads +
-│   ​    ​│   └── develop +
-│   ​    ​└── remotes +
-│   ​        ​└── origin +
-│   ​            ​└── HEAD +
-├── ​objects +
-│   ├── info +
-│   └── pack +
-│   ​    ​├── pack-8d8045f638534ca1ad0f371994e571b65a330b5a.idx +
-│   ​    ​└── pack-8d8045f638534ca1ad0f371994e571b65a330b5a.pack +
-├── ​packed-refs +
-└── ​refs +
-    ├── heads +
-    │   └── develop +
-    ├── remotes +
-    │   └── origin +
-    │   ​    ​└── HEAD +
-    └── tags +
- +
-16 directories,​ 24 files+
 $ $
 </​code>​ </​code>​
  
-==== Committing the submodule ​====+==== Running "git diff" ​====
  
 <​code>​ <​code>​
-$ git commit ​-am "added coroutine2 ​submodule" +$ git diff --cached 
-[master bec4c94added coroutine2 submodule +diff --git a/​.gitmodules b/​.gitmodules 
- 2 files changed, 4 insertions(+) +new file mode 100644 
- create mode 100644 ​.gitmodules +index 0000000..d0564c5 
- create ​mode 160000 ​coroutine2 ​    <-- weird mode for submodule+--- /dev/null 
 ++++ b/​.gitmodules 
 +@@ -0,0 +1,3 @@ 
 ++[submodule ​"​coroutine2"​] 
 +      path = coroutine2 
 ++       url = https://​github.com/​boostorg/​coroutine2 
 +diff --git a/​coroutine2 b/​coroutine2 
 +new file mode 160000 
 +index 0000000..0233d35 
 +--- /dev/null 
 ++++ b/​coroutine2 
 +@@ -0,0 +1 @@ 
 ++Subproject commit 0233d35081de5b669c60ef8ec5a53854e1b2a577
 $ $
 </​code>​ </​code>​
  
-at which point you can push the result:+Abbreviated form:
  
 <​code>​ <​code>​
-$ git push origin master +$ git diff --cached --submodule 
-</code> +diff --git a/.gitmodules b/​.gitmodules 
- +new file mode 100644 
-===== Under the hood ===== +index 0000000..d0564c5 
- +--- /dev/null 
-The submodule directory has a //file// named ''​.git''​not a //​directory//​which refers to submodule ​information in the superproject:​ ++++ b/.gitmodules 
- +@@ -0,0 +1,3 @@ 
-<​code>​ ++[submodule ​"​coroutine2"​] 
-$ cat coroutine2/.git ++       path = coroutine2 
-gitdir../.git/modules/coroutine2++       url = https://github.com/boostorg/coroutine2 
 +Submodule coroutine2 0000000...0233d35 (new submodule)
 $ $
 </​code>​ </​code>​
  
-From the superproject,​ you can see the information for each submodule:+==== Committing ​the submodule ​====
  
 <​code>​ <​code>​
-ls -l .git/​modules/​coroutine2/​ +$ git commit ​--m "added coroutine2 submodule"​ 
-total 48 +[master a7561cb] added coroutine2 submodule 
-drwxrwxr-x. 2 rpjday rpjday 4096 Feb 13 15:37 branches + ​2 ​files changed, 4 insertions(+) 
--rw-rw-r--. 1 rpjday rpjday ​ 297 Feb 13 15:37 config + create mode 100644 ​.gitmodules 
--rw-rw-r--. 1 rpjday rpjday ​  73 Feb 13 15:37 description + create mode 160000 coroutine2 ​   <--- weird mode representing submodule
--rw-rw-r--. 1 rpjday rpjday ​  24 Feb 13 15:37 HEAD +
-drwxrwxr-x. ​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>​ </​code>​
  
-===== Cloning a project with submodules ===== +at which point you can push the result:
- +
-If you don't want to populate ​the submodule directories:+
  
 <​code>​ <​code>​
-$ git clone https://​github.com/​boostorg/​boost +$ git push origin master
-</​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