Git clone vs Git submodule
April 17, 2008 8 Comments
Having recently made the switch from svn to git, I wanted to achieve what svn externals did (and what Piston did better). Turns out this is pretty simple, for example to get rails on edge:
A JavaScript Architect
April 17, 2008 8 Comments
Having recently made the switch from svn to git, I wanted to achieve what svn externals did (and what Piston did better). Turns out this is pretty simple, for example to get rails on edge:
Great post! This really helped out a lot in understanding how to migrate to git from svn. I had been using svn:externals, and the git submodule approach does seem a lot better!
and where’s the “vs” git clone in this article?
@Matt glad it helped :)@kain clone is the default way of checking out a repository instance but submodule does a fairly similar thing. I guess I thought that too obvious to mention what clone does and just concentrate on the differences. Sorry about that, does it make more sense now?
Thanks for the article.
Thanks for posting this… so now if you want to update the submodules to newer revs, do I simply do a ‘git pull’ in them and then commit in the super-tree to get new refs for them stored in the index?
@Anonymous yes that’s correct – cd into the submodule’s directory and do a git pull. You’ll then need to cd into your main repo’s directory, add your changes using git add, commit and push.When someone else pulls next, they can run git submodule update which will update their submodules to the version you just pulled.If you had added a new submodule, the other person would need to run git submodule init again before git submodule update.
git submodules are handy. So is git-svn. Can the two play nice or do you need an intermediategit-svn repository?i.e. I'm running a git project A. I want to track an external project, a django plugin say, as a submodule of A. But that external project uses svn repo X. Do I need to make a git repo B that tracks X with git-svn, then track B as a submodule of A, or can I track X in A without an explicit repo B ?
Thanks for the great tutorial! Here's another article about submodules that extends a little bit on this functionality:http://doblock.com/articles/using-git-submodules-to-manage-plugins-in-rails