user1914292
user1914292

Reputation: 1556

How do I duplicate a Git repository including submodules?

I want to duplicate a repository, that also has a submodle - which is it's own repository.

When I duplicate the top-level repository (using the method described in GitHub's help pages), only the top repository is duplicated, and the submodule is still linked to the original repository.

However, I want to (temporarily) make both repositories private and thus be able to edit both as full duplicates.

How can I do that?

Upvotes: 1

Views: 667

Answers (2)

user1914292
user1914292

Reputation: 1556

For anyone running into the same problem, here's what I did:

  • duplicate the top repo in GitHub with their web form (https://github.com/new/import)
  • duplicate the submodule in GitHub with the same form
  • in the top repo: open the .gitmodules file and replace the submodule reference
  • git add .gitmodules
  • git commit & git-push

Worked like a charm.

Upvotes: 0

Keif Kraken
Keif Kraken

Reputation: 10670

You would want to create a fork of both the repo and any Sub modules into a private repo. Then you would just remove the submodule from the original repo, then add a new submodule from your fork.

HERE's a link that covers how to fork a public repo into a new private repo.

and HERE's a great post on removing and updating submodules.

Upvotes: 1

Related Questions