Reference or use git/github-managed code in your git project

Please note that there seems to be better way to do this since git version 1.8.2 (mentioned in these two stackoverflow answers: here and here). The version from the Ubuntu 12.04 repos is 1.7.9.5 though so I’ll take a different route. The project for this example is the handy node.js multi-platform support layer libuv.

Please note that this example expects you to already have an existing project under git control. If you don’t – simply look up on how to create one using git init or git clone one 🙂


# do a "clean cut" before adding the submodule
git commit

# add libuv to the project
git submodule add https://github.com/joyent/libuv.git libuv
git status

# update the submodule
git submodule init
git submodule update

# enforce the version we want to use (tag v0.10.22)
cd libuv/
git reset --hard v0.10.22
cd ..
git commit -a

git submodule status

You can now reference/include the files of the submodule while still being able to update the submodule to newer versions. Gotta love version control!