2

As part of a personal project, I've started to use git instead of subversion, maybe I'm learning something new from that.

Setting up the repository was fairly easy, configuring my web server to serve the git file works like a charm; commiting, cloning, no problem here.

However, I have some issues with my project setup within the repository. Currently it looks like this:

project.git \- mobileapp \- artwork \- backend \- website 

website and mobileapp are supposed to communicate with backend once everything works.

My problem now is the deployment: When I want to deploy the backend on my server, currently I'd need to checkout the whole repository and copy the contents from backend to my webroot dir.

As there seems to be no way to just checkout the contents of project.git/backend, I am thinking of separating the four subprojects into four git repositories, with the added overhead of maintaining four repositories.

Is there an easier way to solve my problem?

2
  • 2
    submodules could be useful Commented Dec 26, 2012 at 18:58
  • What about just doing what you do now, cloning to some location on your server and then using a post-hook that copies backend to the production area after it receives, and restarts whatever server processes neccessary? Commented Dec 27, 2012 at 0:07

2 Answers 2

3

You are correct that there is no particularly easy way to checkout a partial Git repository. (As of 1.7.0, Git has support for sparse checkout but that may not address your needs.)

The typical recommendation is to put each logically separate module into a separate repository. Managing the relationship between these modules is somewhat difficult.

One approach is to use Git submodules. This adds metadata inside a parent Git repository that teaches Git how to checkout the appropriate versions of child repositories. You then manage the relationship by making individual commits that bump that metadata.

Another is to use an external tool like Android's repo tool. Repo maintains its own state regarding the multiple child repositories as well, but unlike sub-modules, which is very revision focused, repo is more branch focused.

The two approaches are both workable and show a philosophical difference in how to think about the relationship between modules. This is not necessarily a "simpler" way to solve your problem, of course.

Sign up to request clarification or add additional context in comments.

Comments

1

Use submodule:

$ git submodule -h 

E.g.

$ git submodule add [email protected]:<username>/backend.git backend 

Then you can also treat backend as a separate project.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.