1

Cloning git repo from remote server to local computer is rather easily done the standard way, but I need to clone a remote repo into another remote repo, is it possible?

P.S. I come up with this problem because I just can't fork my own project on GitHub to create a child project, I can fork the projects of other users only. This is about cloning to make a whole child project from parent project, not just a submodule.

Hugo y
  • 1,421
  • 10
  • 20
Dee
  • 7,455
  • 6
  • 36
  • 70
  • Possible duplicate of [Git Clone Into Another Existing Git Repo](http://stackoverflow.com/questions/10360342/git-clone-into-another-existing-git-repo) – hek2mgl Jan 17 '16 at 12:38
  • i need to clone the whole parent project into child project, not just a submodule. And github server is where i can't get in to type my own commands in the terminal – Dee Jan 17 '16 at 12:43

1 Answers1

4

Cloning git repo from remote server to local computer is rather easily done the standard way, but I need to clone a remote repo into another remote repo, is it possible?

In git you can't have .git folder inside another git folder

What can you do?

  • Clone the original repo
  • Add new remote git remote add <origin2> <url2>
  • Use the code from both the repositories inside a single repo

Now you can pull and merge the branches from the 2 remotes and have the code of both of them in a single repository.

As you can see in the image below you will have 2 repositories which builds up your big repository.

# clone first repository
git clone <repo1>

# add remote 
git remote add <remote2> <url2>

# display the list of all the remotes
git remote -v

Note: <remote2> can not be an existing remote name.


enter image description here

Enkuushka
  • 425
  • 1
  • 5
  • 12
CodeWizard
  • 128,036
  • 21
  • 144
  • 167