Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git - forgot to use --recursive while cloning [duplicate]

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 that git clone parent_repo actually puts data in the submodule folder?

For example, http://github.com/cwolves/sequelize/tree/master/lib/, nodejs-mysql-native is pointing at an external git submodule, but when I checkout the sequelize project, that folder is empty.

like image 705
Nobody Avatar asked Sep 26 '10 07:09

Nobody


People also ask

What does -- Recursive do git clone?

You can use the --recursive flag when cloning a repository. This parameter forces git to clone all defined submodules in the repository.

What would happen if you cloned an existing git repository?

When you clone a repository, you copy the repository from GitHub.com to your local machine. Cloning a repository pulls down a full copy of all the repository data that GitHub.com has at that point in time, including all versions of every file and folder for the project.

Do you have to clone repository every time?

Once you have cloned a repository, you won't need to clone it again to do regular development. The ability to work with the entire repository means that all developers can work more freely. Without being limited by which files you can work on, you can work on a feature branch to make changes safely.

Does git clone affect original?

When you clone a repository, any changes you push to GitHub will affect the original repository. To make changes without affecting the original project, you can create a separate copy by forking the repository.


1 Answers

With version 2.13 of Git and later, --recurse-submodules can be used instead of --recursive:

git clone --recurse-submodules -j8 git://github.com/foo/bar.git cd bar 

Editor’s note: -j8 is an optional performance optimization that became available in version 2.8, and fetches up to 8 submodules at a time in parallel — see man git-clone.

With version 1.9 of Git up until version 2.12 (-j flag only available in version 2.8+):

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

With version 1.6.5 of Git and later, you can use:

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

For already cloned repos, or older Git versions, use:

git clone git://github.com/foo/bar.git cd bar git submodule update --init --recursive 
like image 121
Mathias Bynens Avatar answered Sep 23 '22 01:09

Mathias Bynens