Cloning a Git repository which contains Sub modules

If you are a new collaborator joining the project, you'd start by running git clone to download the contents of the repository. At this point if you peek inside the sub-module folder, you'd see nothing. Git expects us to explicitly ask it to download the sub-module's contents. You can use git submodule update –init –recursive here. But if you are cloning for the first time, you may use a modified clone command to ensure you download everything, including any sub-modules by running: git clone –recursive

Cloning with git version 1.6.5 and later

 git clone --recursive git://github.com/foo/bar.git 


Cloning with git version 1.9 and up to 2.12

 git clone --recursive -j8 git://github.com/foo/bar.git 

-j8 is an optional optimization that became available in version 2.8 and fetches up to 8 sub-modules at a time in parallel. See man git-clone.


Cloning with git version 2.13 and later

With 2.13 of git and later, –recursive has been deprecated and –recurse-submodules should be used instead:

 git clone --recurse-submodules -j8 <project url>

 

For already cloned repos and older git versions, use below

	git clone git://github.com/foo/bar.git
  	cd bar
	git submodule update --init --recursive
	

Comments

So empty here ... leave a comment!

Leave a Reply

Your email address will not be published. Required fields are marked *

Sidebar



Do NOT follow this link or you will be banned from the site!