Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a new repository which is a clone of another repository?

Tags:

git

github

I have a project "MyfirstProject" in github. Now I am making another project "SecondProject" by cloning "MyfirstProject" since core codes will be the same.

Whenever I updates in "MYfirstProject" I just pull for updates.

Now I want to make a repository for this "SecondProject" in github since I have to work in different computers and it will have different codes from "MYfirstProject".

I don't think branching out is right thing to do since I will never merge them.

How can I do?

Do I need to push to a new repository? Won't it affect pulls from "MyfirstProject"?

What do you do?

Thanks in advance.

like image 513
shin Avatar asked May 17 '11 17:05

shin


People also ask

Does git clone create a new repo?

Usage. git clone is primarily used to point to an existing repo and make a clone or copy of that repo at in a new directory, at another location. The original repository can be located on the local filesystem or on remote machine accessible supported protocols. The git clone command copies an existing Git repository.


1 Answers

There's probably several ways to do this, including a smarter one, but this is how I would do this:

  1. Make a new repo on Github called SecondProject.
  2. Locally clone your MyfirstProject, either from disk or from Github. Then use git pull on the branches you need to move to the second repo.
  3. git remote set-url origin [email protected]:yourname/SecondProject.git
  4. Push it.

Note that the clone retains a shared history with MyfirstProject, which is useful if you change your mind about the "never merge" bit.

like image 74
Fred Foo Avatar answered Oct 24 '22 10:10

Fred Foo