Search code examples
gitgit-push

How to disconnect project to github repo and connect to another?


I'm a little lost. I worked on a project, which is coupled with github. But I made the project evolve and therefore I created on github a new repository with which I wish to work (while keeping aside the old one with the old files).

So in my project I want to make sure that it is no longer coupled to the old repository and that I can work normally from the new one.

I followed some links and so I did:

  • Creation of my new repository on Github
  • In my project : git remote rm origin
  • git remote add origin [newGithubURL]
  • git init , git add . , git commit -m "first commit"
  • git push origin master

But I've this error :

enter image description here


Solution

  • @Mike Faber provided a great solution that would retain the history of the old repository within the new one.

    If you want to start over from scratch as if it were a brand new repository, what I have done is:

    1. Copy the local working folder for the old repository to a new folder
    2. Rename the new folder to what you want it to be, or, archive or rename the old folder as a backup
    3. Delete the .git folder in the new working folder
    4. In the new folder, do git init, git add . , git commit -m "first commit" as you normally would to push to GitHub

    Now you have a copy of the old repository, as a new repository, starting with only one commit.