Git clone vs Git submodule

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:

8 Responses to Git clone vs Git submodule

  1. Matt Jones says:

    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!

  2. kain says:

    and where’s the “vs” git clone in this article?

  3. Edward Spencer says:

    @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?

  4. falker911 says:

    Thanks for the article.

  5. Anonymous says:

    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?

  6. Edward Spencer says:

    @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.

  7. Anonymous says:

    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 ?

  8. Mike Zazaian says:

    Thanks for the great tutorial! Here's another article about submodules that extends a little bit on this functionality:

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: