Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I make a "deep copy" of a git repository with submodules?

It is easy to clone an entire project plus all its submodules:

git clone --recursive [email protected]:homer/powerplant.git

However, how do I create a clone that has all these submodules replaced by the HEADs of the individual sub-repositories themselves? Preferably in such a way that this can be repeated easy, as soon as something changes. The target should be a read-only "flat" version of the same overall code. No merging should be necessary.

If this is possible, it would solve my Launchpad problems where bzr can import only repositories without submodules.

like image 783
Anne van Rossum Avatar asked Nov 26 '25 02:11

Anne van Rossum


1 Answers

If you want to start with submodules' files but not as git repos, simply do the following:

  • clone recursively git clone --recursive [email protected]:homer/powerplant.git (insane repo name btw)
  • then un-register the submodule with git config --remove-section submodule.name

You'll end up with what you want, submodule files in the working tree but submodules not initialized as such.

You could have used the newest git submodule deinit command, but it also removes submodule's files from the working tree.

like image 196
CharlesB Avatar answered Nov 28 '25 16:11

CharlesB



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!