git submodules, subtrees or else

风流意气都作罢 提交于 2019-12-11 07:57:57

问题


Probably, i misunderstood how git works, I have my directory structure as follows:

project (git-repo)
  project 1 (git-repo)
  project 2 (git-repo)
  common scripts (git-repo)

All these folders have their own repositories where the main project can have child repositories such as project 1, project 2, child scripts. They can be submodules or subtree. The problem, the common scripts contain some of the codes that is common and essential to build both project 1 and project 2. What can be best strategy to maintain this so that each project can be independent as well as no need to keep common scripts in two places.


回答1:


I just want to leave the indirect solution that I have figured out. It might be useful for others until getting other approaches.

For now, I am not able to escape not keeping the common scripts folder in two places but It is okay to maintain it in one place. Following is the structure I have adopted for now,

project
  project 1 (git-repo)
    common-script (git-repo/submodule)
  project 2 (git-repo)
    common-script (git-repo/submodule)
  common-script (git-repo)

That way, I can work on the common-script from its own repo and from each of the project I can use git submodule foreach git pull origin master and commit the repo so that I will have updated script in each of the dependent projects.



来源:https://stackoverflow.com/questions/54172820/git-submodules-subtrees-or-else

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!