I currently use SVN to manage jboss server configurations and i need to have several copies of the same sub-directory in each working copy, but referencing the same directory on the server so that when i change some file, every copy gets the update.
Example:
- /server/bin (shared)
- /server/node-01 (copy of repository /server/node)
- /server/node-02 (copy of repository /server/node)
Is it possible to achieve the same using git? I could not find a definitive answer in the (maney) similar questions.
The best approximate I know of is git-submodule [1].
You can define sub-repositories and have the "parent" repository conceptually contain a hash specifying the exact revision each sub-repository should have.
When your HEAD moves in the sub-repository, "git status" and "git diff" will report that as a hash change in the parent repo.
Unfortunately, git submodules are a bit clunky:
When you pull in the parent repo, it will not automatically update the child repos. Instead, the child repos will appear as though you've made local changes (that revert their new position back to where they were).
You have to explicitly call "git submodule update" every time (or script it, of course) after you pull/merge the parent repo.
This also means that "git rebase" and other operations on the parent do not work as well in the presence of submodules. But you do have fine-grained control over the behavior here, so there's nothing you cannot work around.
[1] http://kernel.org/pub/software/scm/git/docs/git-submodule.html