0

I have multiple repos always with only master branch. Lets call them repoA/master, repoB/master, repoC/master. Now I would like create new repo newRepo that would have branches: repoA, repoB, repoC...

Then I would like to copy repoA/master to newRepo/repoA, repoB/master to newRepo/repoB, repoC/master to newRepo/repoC. Finally, I want to delete repoA, repoB, repoC. This way, I will have previously 3 separated repos in one.

Potentially submodule could do it? But what would happen if the origin repo would get deleted? Thank you!

EDIT: Based on the comment section I should have specified that the goal is also to keep commit history for each repo.

Lukas Bunat
  • 73
  • 1
  • 13
  • 2
    Submodules are not branches, they **are** separate repositories. They require separate remote repositories if you ever would want to publish your superproject to colleagues or the general public. – phd Mar 25 '21 at 21:21
  • 1
    Does this answer your question? [How do you merge two Git repositories?](https://stackoverflow.com/questions/1425892/how-do-you-merge-two-git-repositories) – D M Mar 25 '21 at 21:22
  • 2
    I think the [second answer](https://stackoverflow.com/a/10548919/14956277) in the dupe target I linked covers merging repositories. – D M Mar 25 '21 at 21:22
  • Can you clarify what you’re trying to achieve by doing this? Why wouldn’t you just push the master branch of each repo to a new repo with a different branch name? I can give instructions for this, if that’s what you’re asking for. Or why wouldn’t you just have a folder for each repo in one repo? – JBallin Mar 25 '21 at 22:48
  • 1
    Do you want to keep the history of the original repos or just start the branches in newrepo with the current contents of the original repos? – miguelbernadi Mar 26 '21 at 08:00
  • Hi, thanks for the answers. I edited my question -> I want to keep commit history for each repo. Actually, I was trying similar steps as suggested by @DM in [this answer](https://stackoverflow.com/questions/1425892/how-do-you-merge-two-git-repositories/10548919#10548919). I was following [this question](https://stackoverflow.com/questions/21353656/merge-git-repo-into-branch-of-another-repo/21353836), but during 2nd repo git wanted to merge all files despite having 2 branches already. Maybe it was because I didn't remove 1st remote repo? – Lukas Bunat Mar 26 '21 at 08:11

0 Answers0