更新时间:2023-01-17 18:28:01
我研究了Scott Weldon的解决方案.它将起作用,但是git子树似乎将所述目录拆分为自己的存储库.至少那是我从阅读手册和书本中学到的东西,而并非如此. (如果我错了,可能就是这种情况,请让我知道.)那不是我想要做的.
I researched Scott Weldon's solution. It would work, but it seems git subtree splits the said directory into its own repo. At least that's what I gleaned from reading man pages and books and what not. (If I'm wrong, which may well be the case, please let me know.) That's not what I wanted to do.
但是,我确实找到了解决问题的方法.这是我在项目中使用Git子树合并策略(而不是GIT SUBTREE命令)所做的事情:
I did, however, find the solution to my problem. Here's what I did using the Git Subtree Merge Strategy (instead of the GIT SUBTREE command) in my project:
$ git remote add my-library <my-library-url>
$ git fetch my-library
$ git checkout -b my-library-branch my-library/master
$ git checkout master
$ git read-tree --prefix=<desired/library/dir> -u my-library-branch
$ git commit -m "Merged library project as subdirectory"
$ git push
效果很好.我的图书馆在合理的子文件夹中.诚然,我必须带走整个库,而不仅仅是像自定义组件或提供程序这样的大块,在这种情况下就可以了.
This worked great. I have my library in a reasonable subfolder. Admittedly, I have to take the whole library, not just a chunk like a custom component or provider, but that's OK in this case.