Search code examples
githubbitbucketatlassian-sourcetreetortoisegit

How to link files to different/multiple repositories?


Let's say, I have project/repository folder (with it sub folders/files), example structure:

MyProject
 - Folder_1
 -- file_A   
 -- file_B
 - Folder_2
 -- file_C
 -- file_D

I have two needs:

  1. I want to add another developer, who should access only:
MyProject
- Folder_1
-- file_A
- Folder_2
-- file_D
  1. I need also, that I could link Folder_2 to another repository. Is that possible that a folder were linked to multiple repos?

However, on my Windows (I use TortoiseGit), I am unable to achieve "multi-linked" repos idea.


Solution

  • No need for "another repository"

    You can simply make a branch in the same repo, where you remove any elements you don't want, in order to leave only:

    - Folder_1
    -- file_A
    - Folder_2
    -- file_Deave only
    

    Your developer can work in that branch of the same repository. See "TortoiseGit Manual / Branching/Tagging"

    TortoiseGit → Create Branch...
    

    https://tortoisegit.org/docs/tortoisegit/images/Branch.png


    that I could link Folder_2 to another repository.

    Then you can delete Folder_2 (in that branch made for your developer), and declare your remote repo as a submodule under the path Folder2.
    See TortoiseGit submodules.

    https://tortoisegit.org/docs/tortoisegit/images/GitSubModuleAdd.png