Is it possible to have files from multiples paths into one git repository?

96 views Asked by At

We have a commercial WordPress Theme that come packaged with a few plugins. The plugins are part of the theme, they are not sold separately nor usable without the theme.

The theme goes in the following path:

/wp-content/themes/MyTheme/

While the associated plugins go in the following path:

/wp-content/plugins/MyPlugin/

We do not want to have one different repository per plugin. As the whole theme and plugins rely on each other, are updated at the same time, and couldn't work independently.

When we add a feature, we add code to both the plugin and the theme, and then commiting. It would make absolutely no sense to commit to two repositories each time we make changes.

The reason why we separate some features into an external plugin instead of incorporating them into the theme itself is because we are required to do so according to the rules of the marketplace where this theme is made available.

Finally, we would not want to have the repository on the entire /wp-content/ directory, it would require too many git-ignore entries, especially as we have other themes with each their respective repository. Beside, while it is not really an issue, the current file structure allow to click "Download" any tag/branch on GitHub/Bitbucket and upload straight to the WordPress Admin and the theme works as is, while if the file structure started from /wp-content/ then the user will have to extract the files, recover the theme part, create a new ZIP with that fixed file structure (to avoid using FTP) and finally being able to upload it to the WordPress admin.

So, is there any way to have one repository with multiples paths?

I've read about symlinks in this other question but just like the asker said:

"i dont really want any mixing of the two folders on my computer"

1

There are 1 answers

0
VonC On

On way would be to consider the git directory (the .git) and the working tree as separate.

"I don't really want any mixing of the two folders on my computer"

As long as you have a repo with a different structure/content than the one actually using those files (wp-content), you will have to deal with two folder structures to deal with

Your repo (with only the your theme and plugin files) can be checked out somewhere.
Your WordPress structure can be developed somewhere else.

Even if you don't want to use symlink, you can still make your git repo aware of any change in the wordpress folder with:

cd /your/repo
git --work-tree=/path/to/wp-content status
git --work-tree=/path/to/wp-content add .
...