Posts Tagged ‘vcs


Git Submodules

I have been wanting to learn more about Git Submodules and how they work, so I watched the screen cast at the bottom of (would have embedded it, but there were issues doing so). The bottom line is that the Super module contains a reference to a specific version of a Sub module. Git’s submodule command can then determine if you have a different version of the Sub than you should, it can fetch the current version, etc.

The process sort of goes like this, using C1 for Computer 1 and C2 for Computer 2:

  1. C1: change Submodule
  2. C1: commit Super module, freezing version of Sub used by Super
  3. C1: push Super module
  4. C2: pull Super module, gets the updated Sub module version SHA
  5. C2: submodule update, gets the updated Sub code corresponding to the version in #4.

Some observations:

  • Will a user ever do 4 and NOT do 5? Why?
  • If 4 and 5 are tied together, why is that not one step (ala git push = git fetch; git merge origin/master)?
  • C2 has no idea to update the Sub code unless they are carefully watching the pull output or run git submodule status directly after 4 above to know that a Sub update is needed
  • Possible source of issues if C2 has Version x+1 of Super but only version x of Sub

Now, I’m new to Git, but it would seem to me that one could write a hook that would automatically run git submodule update if .gitmodules is present in the directory. It would seem that an appropriate hook to git pull would be to add git submodule update after the pull. Am I missing something here?

I understand that git’s submodule support has been added-on as submodules were not something in the design of Git. I wonder if the lack of these hooks and a better user experience is the direct side effect of that bolt-on?

Mercurial seems to be trying to do this via it’s subrepos support:

Whenever newer Mercurial versions encounter thisĀ .hgsubstate file when updating your working directory, they’ll attempt to pull the specified subrepos and update them to the appropriate state.

Enough to make me switch? Not if I can write a hook.


Twitter Updates

Error: Twitter did not respond. Please wait a few minutes and refresh this page.