Skip to content

Instantly share code, notes, and snippets.

@sprhawk
Created November 23, 2011 17:08
Show Gist options
  • Save sprhawk/1389234 to your computer and use it in GitHub Desktop.
Save sprhawk/1389234 to your computer and use it in GitHub Desktop.
git command: submodule
$ git submodule add (NOTE: Do not use local URLs here if you plan to publish your superproject!)
Pulling down the submodules is a two-step process. First run git submodule
init to add the submodule repository URLs to .git/config:
$ git submodule init
$ git submodule update
If you want to make a change within a submodule and you have a detached head, then you should create or checkout a branch, make your changes, publish the change within the submodule, and then update the superproject to reference the new commit:
$ git checkout master
or
$ git checkout -b fix-up
then
$ echo "adding a line again" >> a.txt
$ git commit -a -m "Updated the submodule from within the superproject."
$ git push
$ cd ..
$ git diff
diff --git a/a b/a
index d266b98..261dfac 160000
--- a/a
+++ b/a
@@ -1 +1 @@
-Subproject commit d266b9873ad50488163457f025db7cdd9683d88b
+Subproject commit 261dfac35cb99d380eb966e102c1197139f7fa24
$ git add a
$ git commit -m "Updated submodule a."
$ git push
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment