How can I add a specific folder when using git subtree?

后端 未结 2 740
执笔经年
执笔经年 2021-02-09 15:03

I have a complicated Ionic project I\'m developing. Many of the components and providers I\'m developing are generic and can be used in other projects my company is doing. This

2条回答
  •  生来不讨喜
    2021-02-09 15:37

    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.

    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 
    $ git fetch my-library
    $ git checkout -b my-library-branch my-library/master
    $ git checkout master
    $ git read-tree --prefix= -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.

提交回复
热议问题