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!
CodePudding user response:
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.
CodePudding user response:
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.