I have recently started a new project which is very similar to a project that I have already completed. As such, I cloned the previous project and made substantial changes to a point where the new project is now complete. However, I now want to commit this new project to a new git repository, but if I were to simply push these new changes they will push onto the existing project. Using git on the command line, how do I create a new repository on GitHub/GitLab to which I can push my new project, and change the destination of this commit to the new repository?
Asked
Active
Viewed 218 times
0
-
1If you poke around on the site, such as [here](https://stackoverflow.com/questions/2432764/how-to-change-the-uri-url-for-a-remote-git-repository), you will find a lot of resources for how to handle your situation. – Tim Biegeleisen Jun 10 '19 at 11:12
-
3Possible duplicate of [How to change the URI (URL) for a remote Git repository?](https://stackoverflow.com/questions/2432764/how-to-change-the-uri-url-for-a-remote-git-repository) – Joe Jun 10 '19 at 11:26
2 Answers
1
You should have forked the project, not clone. Forking creates a separate copy of the project, so the remote is different.
Create a new project from the UI in Gitlab/Github.
Check your remote with:
git remote -v
- Change the remote to the new project with the command:
git remote set-url origin git@github.com:USERNAME/REPOSITORY.git
Note: you have to have rights to push to the original project, so even if you try a push it may not succeed.
More details here [1].
[1] https://help.github.com/en/articles/changing-a-remotes-url

anegru
- 1,023
- 2
- 13
- 29
0
Another option if you do not want to retain the history of the other project would be to create your new project in Git Hub, clone that project down locally, and copy the source files over to the new directory (do not copy the .git directory). Again, this is only if you do not want to retain history, otherwise see the answer from Adrian Negru.

dmoore1181
- 1,793
- 1
- 25
- 57