Project attached to the wrong github repo

Hello,

So, I was trying to back up a new project through terminal and somehow I attached new project to the repo for an existing project and I don’t know how this happened or how to fix it.  Is there anyway to remove the new project and have it not be connected to the existing project’s repo without messing up the existing project?? 

I checked and all of my other projects are attached to the right repos on github, so somehow I just messed up this particular one.

Still kinda new to git and github and I’m hoping this is an easy fix.

Screen Shot 2017-11-16 at 8.17.49 AM.png

-Amanda

1 Like

Have you committed and pushed the new repo to Github yet?

If not you are in luck and you can simply set the remote back to the right project using the steps shown here.

If yes, then the history of the project has changed dramatically and you have two options. But first do the above step to make sure that all your projects are in line.

Option 1

Rewrite the history of the project. This is probably what I would recommend if you are the only one working on the project. It will restore your project to where it was prior to the change.

Todo this have a look back in your log and find the commit you want to go back to using…

git log

Then move back to that commit using…

git reset --hard <sha1-commit-id>

This will only make the changes locally though, to push the changes to Github you need to force it using…

git push origin HEAD --force

Option 2

Actually writing this I think you probably want option 1. I was going to make option 2 reverting your latest commits. But it is pretty unlikely that other people are using the new project as a baseline for other work.