How to clone only a folder from a git submodule?

前端 未结 3 525
孤独总比滥情好
孤独总比滥情好 2020-12-24 10:24

I\'m trying to get just a folder from an external github repo to use in my project.

I want my project setup to be like this:

-my_project
    -submodu         


        
相关标签:
3条回答
  • 2020-12-24 10:37

    If you:

    git submodule add http://github.com/user/submodule.git
    

    directly under my_project, you should end up with the desired organization of directories.

    From git submodule add man page:

    The optional argument <path> is the relative location for the cloned submodule to exist in the superproject.
    If <path> is not given, the "humanish" part of the source repository is used ("repo" for "/path/to/repo.git" and "foo" for "host.xz:foo/.git").

    0 讨论(0)
  • 2020-12-24 10:43

    What you want to do is not feasible because you cannot clone a part of a repository.

    See details in duplicate How to change a git submodule to point to a subfolder?

    0 讨论(0)
  • 2020-12-24 11:02

    just

    git submodule update --init --recursive
    

    in the root-directory of your project and it should do what you want

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