michael
michael

Reputation: 110570

How can I create a new git project based on an old git project

I have been development using git after I clone from a remote repository. I have created a local branch for my own development work. But now I need to create a new git project from my work with a different Directory name. How can I create a new git project which based on the work I did, including all the commits that I did in my local branch which I have not pushed.

Thank you.

Upvotes: 2

Views: 2061

Answers (2)

Kemin Zhou
Kemin Zhou

Reputation: 6891

I had the same problem and was not easy for me to figure out what was involved since I am new to git. I believe the following answer might be more clear to beginners:

git clone <ssh|https>xyz.company.com/foo/bar.git
git remote remove origin
# then create another empty project on abc.company.com
git remote add origin https://abc.company.com/foo/bar.git
git push --force 

What I was doing is to use some public git repositories that the original author does not bother to update or answer any questions. The original program does not even work on the test data. So I am trying start a new project based on this non-working project.

Upvotes: 2

Paul Beckingham
Paul Beckingham

Reputation: 14895

Simply clone the old project and modify the remote. Try this:

$ git clone old.git new.git
$ cd new.git
$ git remote add origin <remote-path>
$ git push origin

This will give you a complete local copy which includes history, and once the remote is modified, it will be a completely separate effort.

Upvotes: 4

Related Questions