News Stay informed about the latest enterprise technology news and product updates.

How to clone a git repository with submodules init and update

If you have a Git repository with submodules, you’ll likely be surprised to find out that a clone of the repository does not bring down all of the branches and code for the associate submodules. A few extra steps need to be taken.

Git clone with submodules

The list of steps required to clone a Git repository with submodules is:

  1. Issue a git clone command on the parent repository
  2. Issue a git submodule init command
  3. Issue a git submodule update command

The git submodule init and update commands are needed to pull down submodule artifacts and resources.

When these three steps are complete, both the parent repository and all submodules will be available locally, and files from the master branch of the parent repository and the submodule will be available in their respective git working trees.

Git init and update alternative

There is actually an alternative go going through these three steps. You can alternatively use the –recurse-submodules switch on the clone. That might be easier.

git clone --recurse-submodules https://github.com/cameronmcnz/surface.git 

Git submodule clone

The commands issued to clone the git repository and all submodules are:

submodule@example:~$ git clone https://github.com/cameronmcnz/surface.git
submodule@example:~$ git submodule init
submodule@example:~$ git submodule update

The clone operation will obviously happen after multiple repositories have been created and submodules added to them. For more information on how to perform other git submodule operations, check out our full listing of ‘git submodule how to‘ tutorials.

You can find both of these repositories on GitHub and GitLab.


Become a Git power user

Want to become a Git power user? Take a look at the following Git articles and tutorials

 

 

 

 

Join the conversation

1 comment

Send me notifications when other members comment.

Please create a username to comment.

Very true and not just access control but need to make sure that infected personal devices will not get into the network and infect/affect/steal info form the corporate network as well as other personal devices connecting to the network. You need a thorough granular access control not just on servers / services it can connect but also what devices and what apps can do what will be powerful. Also today innovative technologies allow to discover, identify, monitor all BYODs in the network without touching them (agentless like i7 network's peregrine7). In reality a very good Secure mobile (byod) access gateway can be the first point to start and monitor, secure, & granular access control. Ofcourse MDMs to provide security to the data on the device and MAMs to provide security and control to enterprise apps.

Manju
Cancel

SearchAppArchitecture

SearchSoftwareQuality

SearchCloudComputing

SearchSecurity

SearchAWS

Close