Pushing subtrees in a git repo

百般思念 提交于 2019-12-04 09:19:30
VonC

Couple of remarks from the comments:

So I recommend:

  • loading (git checkout) the parent repo and all its submodules
  • creating elsewhere the correct structure, with symlink to the submodules (or subdirectories of the submodules in order to achieve what you need.
  • go back periodically to the git ain parent repo in order to detect any changes (dones from the other directory structure created outside of Git) in order to commit and push all submodules modifs, and then commit and push the parent repo.

git checkout

parent repo
  +
  +--> main project
    +
    +-> mainDir1
    +-> mainDir2
  +--> lib1
    +
    +-> lib1Dir1
    +-> lib1Dir2
  +--> lib2
    +
    +-> lib2Dir1
    +-> lib2Dir2

And your own project directory structure (for instance)

  +--> main project (symlink to ../parent/main project)
    +
    +-> mainDir1
    +-> mainDir2
    +-> lib1Dir1    (symlink to ../parent/lib1/lib1Dir1)
    +-> lib1Dir2    (symlink to ../parent/lib1/lib1Dir2)
    +-> lib2Dir2    (symlink to ../parent/lib1/lib2Dir2)

(note there is no lib2Dir1 (for instance) because in your actual project you don't need it)

VonC's solution is neat, but it has a disadvantage: There is no good way of capturing a configuration of your project+libraries at a point in time.

If you need to set up your project again, you'll need to checkout your project + the libraries, but they may all be on different branches and commits to what you had before.

So, if you follow VonC's suggestion, maybe create tags in each of the repos at the point when you make a release of your project, so that you can at least check them out again at the same point.

Otherwise, always move forwards and never check out an older version.

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