Single git repo setup tracking multiple locations on hard drive

I’m very new to the world of git (done some svn in the past) and would like some advice on trying to accomplish the following.

My current workflow is that I setup the static html files using Middleman to get the base HTML structure and styles before porting over to a WordPress template. These static files are located at C:/git/project-name/HTMLTemplates.

Read More

My wordpress setup uses Xampp so the theme files are kept in C:/Xampp/wordpress/wp-content/themes/project-theme.

What I would like to do is have a single git repo that tracks the changes of the two different locations (HTMLTemplates and project-theme)

Is this at all possible, or do I simply create two individual repos (eg: proect-static and project-wordpress)?

Related posts

Leave a Reply

1 comment

  1. No, there is no mechanism in git for this. Git assumes that all files that it manages (the “working copy”) live in a single directory (and subdirectories); there is no support for managing two separate directories in in repo.

    So you’ll have to somehow keep everything in one directory, probably as subdirectories HTMLTemplates and theme or similar.

    You could use two git repos, but I’d strongly advise against this. A single repo should contain a whole “project”, i.e. everything needed to build one piece of software (excluding things like external libraries). If you split your project across two repositories, you cannot usefully branch and merge (because you’d have to do it in both repos simultaneously), you cannot easily check out old versions etc..

    To solve your problem, I see a few possible solutions:

    • Have some build / deployment script that copies everything to the right places. You probably alread have a script that invokes Middleman, and possibly tells WordPress to refresh its cache, so you could add it there.
    • Set up a symbolic link for the wordpress directory. On UNIX-like systems this is easy and commonly done. On Windows, you can create “junction points”, which I believe work similarly.
    • Configure WordPress / Apache to read the directory directly from your git working copy. The path should be configurable.

    I would prefer the first solution; this has the added advantage that it will decouple your development environment from the server configuration. This will make it easier if your setup later changes or your project needs to run in a different environment (development on a different machine, someone else also wants to work on your project, you want to deploy to a hosted server somewhere etc.).

    Note: The problem is, I believe, that your are trying to use git as a deployment tool. While many people do this, git is not really suitable for this purpose. Deployment should usually be a separate step.