


See commit 4c69101 () by Ben Avison ( bavison).


You can initiate fetching the submodule using multiple threads, in parallel.įor instances: git fetch -recurse-submodules -j2Įven better, with Git 2.23 (Q3 2019), you can clone and checkout the submodule to their tracking branch in one command! Update 2016, with git 2.8: see " How to speed up / parallelize downloads of git submodules using git clone -recursive?" With version 1.6.5 of git and later, you can do this automatically by cloning the super-project with the –-recursive option: git clone -recursive git:///mysociety/whatdotheyknow.git See Working with git submodules recursively for the init part. If -recursive is specified, this command will recurse into the registered submodules, and update any nested submodules within. This change reduces the time for git fetch ( man) in my repo from 25s to 6s.Īs joschi mentions in the comments, git submodule now supports the -recursive option (Git1.6.5 and more). Similar logic can be found in cat-file, pack-objects and more. Notify setup_revisions() that the input is not filenames by passing assume_dashdash, so it can avoid redundant stat for each ref.Īlso suppress refname_ambiguity flag to avoid filesystem lookups for each object. The argv argument of collect_changed_submodules() contains only object ids (the objects references of all the refs). (Merged by Junio C Hamano - gitster - in commit 2ce9d4e, ) submodule: suppress checking for file name and ref ambiguity for object ids See commit a462bee () by Orgad Shaneh ( orgads). Note that Git 2.29 (Q4 2020) brings a significant optimization around submodule handling. If you just want to clone them at their recorded SHA1: git clone -recurse-submodules Anyway, you should take into consideration the fact that working with submodules is quite tricky, and you can’t use them for all your projects.Git 2.23 (Q3 2019): if you want to clone and update the submodules to their latest revision: git clone -recurse-submodules -remote-submodules Generally, if you want to keep your projects in different repositories, using submodules is the right decision. The second command will fetch the overall data from the submodule project, checking out the mapped commit in the parent project. git/config file along with the mapping from the. You need to run git submodule init and git submodule update. Note that it won’t clone the files within them. With the help of this command, you can clone the directories with their submodules. You can proceed by using the git clone command. Cloning git submodulesĪnother common action for git submodules is cloning a project with submodules. If you want the principal repository to point at the new commit, you need to invoke the git add command, commit, and finally push it. It will check out the code of the submodule on another commit, not the one that your main repository is pointing at. If you invoke the git status command in your principal repository, the submodule will be in the “Changes not staged for commit” with the following text: “modified content. Git pull -recurse-submodules Pushing updates in git submoduleĪs the submodule represents a separate repository, it allows running the git push command in the directory of the submodule.
