0

I am trying to push to my remote repository on Github, but I keep receiving the following error (from VS Code, same error in Github Desktop):

> git push -u origin main
remote: Repository not found.
fatal: repository 'https://github.com/<user>/<deleted-repository>/' not found

The error says the repository is not found, which is true because it has been deleted.

After using:

$ git remote add origin https://github.com/<user>/<new-existing-repository.git>

My remotes currently look like:

git remote -v
origin  https://github.com/<user>/<deleted-repository.git> (fetch)
origin  https://github.com/<user>/<deleted-repository.git> (push)
origin  https://github.com/<user>/<new-existing-repository.git> (push)

I have tried:

git remote remove origin

which removes the new remote. I have also tried

git remote remove <https://github.com/<user>/<deleted-repository.git>

Neither works.

I also have noticed that for my new remote I only have "(push)", whereas the other one has both "(fetch)" and "(push)".

Edit:

I removed the new remote and tried the following:

$ git remote -v
origin  https://github.com/<user>/<deleted-repository.git> (fetch)
origin  https://github.com/<user>/<deleted-repository.git> (push)

$ git remote remove origin
fatal: No such remote: 'origin'

$ git remote set-url --delete origin https://github.com/<user>/<deleted-repository.git>
fatal: No such remote 'origin'

$ git remote set-url origin https://github.com/<user>/<new-existing-repository.git>
fatal: No such remote 'origin'

Any insight into this issue would be greatly appreciated!

clm
  • 11
  • 3
  • 1
    what happens if you do `git remote remove origin` again **after** it removes the new repo? – bolov Apr 03 '22 at 20:42
  • Likely duplicate of https://stackoverflow.com/questions/11690709/can-a-project-have-multiple-origins – matt Apr 03 '22 at 20:50

2 Answers2

0

Say

git remote set-url --delete origin https://github.com/<user>/<deleted-repository.git>

That will delete the deleted origin.

But I would also suggest that you delete the other origin too and start over. You evidently added the second origin in an incorrect manner.

matt
  • 515,959
  • 87
  • 875
  • 1,141
0

Try this

git remote set-url origin https://github.com/<user>/<new-existing-repository.git>

it should remove old url and will add new one.

since you deleted origin by using

git remote remove origin

now if you will check by

git remote -v 

It won’t return anything

You can simply add new url by

git remote add origin https://github.com/<user>/<new-existing-repository.git>