Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

If you use git submodules, what you do is exactly like tagging. An example from a project I'm working on:

at some point I want to add a submodule for a dependency I need

  $ git submodule add http://github.com/fictorial/redis-node-client.git deps/redis-node-client
this produces a commit with the following diff:

  diff --git a/.gitmodules b/.gitmodules
  new file mode 100644
  index 0000000..1695499
  --- /dev/null
  +++ b/.gitmodules
  @@ -0,0 +1,3 @@
  +[submodule "deps/redis-node-client"]
  +       path = deps/redis-node-client
  +       url = http://github.com/fictorial/redis-node-client.git
  diff --git a/deps/redis-node-client b/deps/redis-node-client
  new file mode 160000
  index 0000000..5050251
  --- /dev/null
  +++ b/deps/redis-node-client
  @@ -0,0 +1 @@
  +Subproject commit 505025187faf3cf7a211f5e6bfd261e45bd0b1dc
Later, when I want to update the subproject to a new revision, i just

  $ cd deps/redis-node-client
  $ git checkout v2.0 # or whatever
  $ cd ../..
  $ git diff

    diff --git a/deps/redis-node-client b/deps/redis-node-client
    index bdbfb96..a98a74b 160000
    --- a/deps/redis-node-client
    +++ b/deps/redis-node-client
    @@ -1 +1 @@
    -Subproject commit bdbfb96293f868dc01917a38af2dc4b66dd86157
    +Subproject commit a98a74b71c1ad90f15c58bb904d17906689c85f5
From the point of view of the parent git repository it only updated the pointer to point to another commit.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: