簡體   English   中英

Git:如何刪除已刪除倉庫的遠程源?

[英]Git: How to remove remote origin for deleted repo?

我正在嘗試推送到 Github 上的遠程存儲庫,但我不斷收到以下錯誤(來自 VS Code,在 Github 桌面中出現相同錯誤):

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

錯誤說找不到存儲庫,這是真的,因為它已被刪除

使用后:

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

我的遙控器目前看起來像:

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)

我努力了:

git remote remove origin

這將刪除新的遙控器。 我也試過

git 遠程刪除 <https://github.com/<user>/<deleted-repository.git>

兩者都不起作用。

我還注意到,對於我的新遙控器,我只有“(push)”,而另一個同時具有“(fetch)”和“(push)”。

編輯:

我刪除了新的遙控器並嘗試了以下操作:

$ 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'

任何對此問題的見解將不勝感激!

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

這將刪除已刪除的原點。

但我也建議您也刪除其他來源並重新開始。 您顯然以不正確的方式添加了第二個來源。

嘗試這個

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

它應該刪除舊的 url 並添加新的。

因為您通過使用刪除了原點

git remote remove origin

現在,如果你會檢查

git remote -v 

它不會返回任何東西

您只需添加新的 url

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM