Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cloning a git repo with all submodules

Tags:

People also ask

How do I clone a project with submodules?

Cloning a Project with SubmodulesIf you pass --recurse-submodules to the git clone command, it will automatically initialize and update each submodule in the repository, including nested submodules if any of the submodules in the repository have submodules themselves.

How do I clone a git repository with all branches?

Use the --mirror Option to Clone All Branches in Git Create an empty directory and navigate to it. Clone your repository with the git clone --mirror command. The --mirror option sets up a mirror of the source repository with all branches.

Does cloning repo clone all branches?

The idea is to use the git-clone to clone the repository. This will automatically fetch all the branches and tags in the cloned repository. To check out the specific branch, you can use the git-checkout command to create a local tracking branch.

How do I download all submodules in git?

Once you have set up the submodules you can update the repository with fetch/pull like you would normally do. To pull everything including the submodules, use the --recurse-submodules and the --remote parameter in the git pull command .


I have a working git repository containing several submodules (obtained by cloning different repositories).

Now, I want to copy the whole repository (with all the submodules) to a bare git repo on a different machine by either using pushing or cloning. I'm fine loosing the history of the submodules (I'm just interested in keeping their content).

Is this possible ? In my attempts, in the cloned repository the submodule directory is empty.

P.S. I know that this is not the correct workflow (see creating a public repo with submodules), however there is no possibility of updating the original submodule.