1

Here is the current setup. I have a:

  • Central Git repository (origin) on a network drive
  • Working copy on my local hard drive
  • Repository on the web server to deploy project to

I use a submodule to pull in a framework that is hosted on GitHub. My understanding is that when I add a subdmodule to my repository, it downloads the repository from GitHub to my local working directory, where I can then checkout the desired version, and ultimately push to the origin.

When I commit the code to the origin repository, does it push a copy of the framework as well, or does it only, for lack of a better word, store a reference/pointer to the remote repository?

I ask because I would like to create a few repositories of third-party tools that I often use with this framework (currently not managed with Git), so that I can easily pull them into the projects that need them. The goal is to then update my local, third-party repositories whenever needed and update the individual projects with a newer version.

The way I deploy my projects is by pushing them to the web server, which will then deploy the application using the post-receive hook. The potential problem might be that if Git doesn't push the submodule itself and only a pointer, which I think is the case, because that's what git submodule init && git submodule update is for, the web server will have no way of getting a copy of the submodule's contents.

The easiest solution I can think of would be to simply host those third-party tools using a public-facing service like GitHub or Bitbucket, but I'm wondering if there's another way?

NightHawk
  • 3,633
  • 8
  • 37
  • 56

1 Answers1

1

When I commit the code to the origin repository, does it push a copy of the framework as well, or does it only, for lack of a better word, store a reference/pointer to the remote repository?

The latter: it store a special entry (as seen here), which means if you have done:

  • any checkout in the submodule (ie. you have changed the HEAD but have not modified any file), you need to go back to the parent repo, add, commit and push that new special entry which reflect the new HEAD SHA1 of your submodule
  • any file modification in your submodule, you need to:
    • add, commit and push that submodule back to its origin
    • go back to the parent repo, add, commit and push.

Your post-receive hook can take care of a git submodule update --init --recursive step.
See this hook for instance.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • +1 since this was helpful, however I'm still wondering about the best way to get a local submodule on to the remote server, if possible, when local can push to remote, but remote can't pull from local. – NightHawk Jul 30 '13 at 21:03