How to copy an entire repository (along with all branches & history) to a folder / directory inside another repository? Can anyone please help by providing the steps / commands?
Are you possibly looking to create a submodule?
A submodule remains a separate repository that’s basically linked into another repository. Inside the submodule directory you can work on that repository as usual.
No. Let me give some more details. Let’s say I have RepoA, RepoB and RepoC. Let’s say RepoA is blank and new. I will have 2 directories called B and C inside RepoA. Now, within directory B of RepoA, I want to copy RepoB (with all branches and history) and within directory C of RepoA, I want to copy RepoC (with all branches and history)
Subtree merging might be a starting point, but it’s not exactly what you want.
I doubt preserving all branches within the combined path structure is workable, though, even though you might find a technical solution. Let’s assume RepoA has just one branch for simplicity (
main), RepoB has three (
dev-2), and RepoC three as well (
So you start combining each of the RepoB branches with RepoA’s
A B /- main / main --- dev-1 \ \_ dev-2
Now, where are you going to add the branches from RepoC? Just onto the
main-main combination? On all three? If you do the latter you end up with nine very confusing branches, and that’s with very low numbers of branches per repository!
A B C / main /- main -- dev-a / \ dev-b / / main main ---- dev-1 - dev-a \ \ dev-b \ / main \_ dev-2 - dev-a \ dev-b
Thank you for your response. Let me try to explain my use case. I want to have entire RepoB inside a subdirectory of RepoA (say DirB) and entire RepoC inside another subdirectory of RepoA (say DirC). Two reasons. GitHub unfortunately doesn’t give us the provision to organize repos inside directories like GitLab. Hence we are forced to spin up and maintain multiple repositories which is a pain. Also, we want to have GitHub actions for the appropriate repos inside the subdirectories based on the Path Ignore option. Hope I am clear.
Basically, I want to create a new Parent Repository (say RepoA) and create folders inside it. Then I want to move an existing repository (say RepoB, along with branches and history) into a folder inside RepoA. Is this possible? If yes, how?
Have you had any luck finding the solution?