Git: Possible to use same submodule working copy by multiple projects?

前端 未结 5 1914
自闭症患者
自闭症患者 2020-11-27 14:41

I\'m new to Git. Lets say, I have two git repositories that have the same library added as submodule:

/home/projects/project1/library_XYZ
/home/projects/proj         


        
5条回答
  •  迷失自我
    2020-11-27 15:13

    I chose for a somewhat easier method (imho):

    I set up the shared submodule as followed:

    1. Clone the project that should serve as the shared submodule locally to some directory
    2. In the shared submodule, modify the local config of this project by adding 'worktree = ..' under [core]

    For all projects sharing this submodule:

    1. Add the submodule (this means, effectively I now have two checked out copies of that project)
    2. Delete the respective submodule folder in ./git/submodule/
    3. Delete the content of the submodule directory apart from the .git file
    4. Modify the .git in the submodule directory to point to the path of the project setup in 1)

    Sidenote: This does not seem to work fine with Sourcetree. For some reason Sourcetree does not get the reference to the project right and always assumes that files are deleted (due to step 5). It works flawlessly using the command line though, which leads to me to believe that the setup is correct, but Sourcetree is bugged.

提交回复
热议问题