I have a git repository with a lot of source files. I would like to create a new repository, where some of the files from the existing repository is referenced into the new repository.
Example:
Repository A contains:
In Repository B I would like to reference source file 3 from Repository A:
Repository B is going to be shared among developers who do not all have access to Repository A.
So my question is: Is it possible to reference some files from one repository to another, such that when developers with access to Respository A changes the original file the changes will be discovered by Repository B? If it is possible, how can I do it?
Git thinks of files as the content of the whole repository, not as a collection of files. Therefore this is quite hard to do. If this feature is critical I suggest you switch to a file-centric SCM system.
However it is possible, but quite clumsy.
create an orphan branch in repo B with the file you want to track. Merge this file into an other branch in repo B, for example the master branch, possible using the subtree-merge algoritm.
You can use gitolite to restrict access to one branch from your repo. Now you can add repo B to repo A with as a submodule or as a remote and doing a subtree merge. (you can read more about how to handle submodules and subtree merges on git-scm.com).
However, you cannot use gitolite to deny reads from the whole repo B, just write access. If you're looking for read prevention as well, you'll need to put the file in a repo C
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With