How to “git clone” including submodules?

后端 未结 15 799
夕颜
夕颜 2020-11-22 05:40

I\'m trying to put a submodule into a repo. The problem is that when I clone the parent repo, the submodule folder is entirely empty.

Is there any way to make it so

相关标签:
15条回答
  • 2020-11-22 05:59

    [Quick Answer]

    You can use this command to clone your repo with all the submodules:

    git clone --recursive YOUR-GIT-REPO-URL
    

    Or if you have already cloned the project, you can use:

    git submodule init
    git submodule update
    
    0 讨论(0)
  • 2020-11-22 06:00

    late answer

    // git CLONE INCLUDE-SUBMODULES ADDRESS DESTINATION-DIRECTORY
    git clone --recursive https://USERNAME@bitbucket.org/USERNAME/REPO.git DESTINATION_DIR
    

    As I just spent a whole hour fiddling around with a friend: Even if you have Admin rights on BitBucket, always clone the ORIGINAL repository and use the password of the one who owns the repo. Annoying to find out that you ran into this minetrap :P

    0 讨论(0)
  • 2020-11-22 06:01

    If it is a new project simply you can do like this :

    $ git clone --recurse-submodules https://github.com/chaconinc/YourProjectName 
    

    If it is already installed than :

    $ cd YourProjectName (for the cases you are not at right directory) 
    $ git submodule init
    $ git submodule update
    
    0 讨论(0)
  • 2020-11-22 06:03

    [Quick Answer]

    After cloning the parent repo (which contained some submodule repo), do as the following:

    git submodule update --init --recursive
    
    0 讨论(0)
  • 2020-11-22 06:04

    Try this for including submodules in git repository.

    git clone -b <branch_name> --recursive <remote> <directory>
    

    or

    git clone --recurse-submodules
    
    0 讨论(0)
  • 2020-11-22 06:05

    Try this:

    git clone --recurse-submodules
    

    It automatically pulls in the submodule data assuming you have already added the submodules to the parent project.

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