1

Imagine that I have a git repository called foo and I want to clone it into another directory named bar.

What I normally could do, assuming that foo is already cloned somewhere on-disk, is this:

git clone foo bar

And that will clone foo into bar. But if foo has submodules, then bar will not get the files in those submodules. Normally, you'd want to use git clone --recursive foo bar to add those submodule files over. That will clone the repository, its submodules, and each submodule's refs into bar.

However this is actually not what I am looking for. I don't want bar to contain any submodules, just the files from foo. Since foo is cloned locally this seemed possible but I don't see in git clone's documentation about how to do it. Is there a way to do what I'm looking for in a (ideally single) command?

ColinKennedy
  • 828
  • 7
  • 24
  • 1
    There *are* ways to do this, but they basically replay all the commits generating new hashes. So you'll end up incompatible in git terms with everyone using the original repo; in a pinch you could still trade email-style raw diff patches, but unless you have something *extremely valuable* and *concise* to contribute they'll probably make you create your own fork of their repo with its submodules intact, re-apply your patches there, and then generate compatible pull requests from that... – Chris Stratton Oct 01 '18 at 21:55
  • 1
    Possible duplicate of [un-submodule a git submodule](https://stackoverflow.com/questions/1759587/un-submodule-a-git-submodule) – Chris Stratton Oct 01 '18 at 21:59
  • Especially read and carefully evaluate the answer there offering "git-submodule-rewrite" – Chris Stratton Oct 01 '18 at 22:01

0 Answers0