Add subdirectory of remote repo with git-subtree

前端 未结 2 552
囚心锁ツ
囚心锁ツ 2020-12-07 13:45

Is there a way to add a subdirectory of a remote repository into a subdirectory of my repository with git-subtree?

Suppose I have this main reposito

2条回答
  •  余生分开走
    2020-12-07 14:36

    I was able to do something like this by adding :dirname to the read-tree command. (note that I'm actually just trying to learn git and git-subtrees myself this week, and trying to setup an environment similar to how I had my projects in subversion using svn:externals -- my point being that there might be a better or easier way than the commands I'm showing here...)

    So for example, using your example structure above:

    git remote add library_remote _URL_TO_LIBRARY_REPO_
    git fetch library_remote
    git checkout -b library_branch library_remote/master
    git checkout master
    git read-tree --prefix=dir1 -u library_branch:libdir
    

提交回复
热议问题