Maintain git repo inside another git repo

后端 未结 4 1617
慢半拍i
慢半拍i 2020-12-07 16:25

Here\'s what I\'d like:

REPO-A
  /.git
  /otherFiles
  /REPO-B
    /.git
    /moreFiles

I want to be able to push all of REPO-A\'s

相关标签:
4条回答
  • 2020-12-07 16:38

    Yes, you can do exactly what you're asking with the file hierarchy you drew. Repo-B will be independant and have no knowledge of Repo-A. Repo-A will track all changes in it's own files and Repo-B's files.

    However, I would not recommend doing this. Every time you change files and commit in Repo-B you'll have to commit in Repo-A. Branching in Repo-B will mess with Repo-A and branching in Repo-A will be wonky (trouble removing folders, etc.). Submodules are definitely the way to go.

    0 讨论(0)
  • 2020-12-07 16:49

    I have always used symlinks to maintain two separate and distinct repos.

    0 讨论(0)
  • 2020-12-07 16:56

    You can achieve what you want (that REPO-A repo contains all the files, including those in folder REPO-B instead of only a reference) by using "git-subrepo":

    https://github.com/ingydotnet/git-subrepo

    It still works if some of your contributors don't have the subrepo command installed; they will see the complete folder structure but won't be able to commit changes to the subrepos.

    0 讨论(0)
  • 2020-12-07 16:57

    It sounds like you want to use Git submodules.

    Git addresses this issue using submodules. Submodules allow you to keep a Git repository as a subdirectory of another Git repository. This lets you clone another repository into your project and keep your commits separate.

    0 讨论(0)
提交回复
热议问题