简体   繁体   中英

Git: How to remove remote origin for deleted repo?

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!

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.

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM