github中的重命名存储库出错,“远程:此存储库已移动。请使用新位置”


177

我收到此通知:remote: This repository moved. Please use the new location [new location]当我将本地实例的更新推送到GitHub上的远程主服务器时。

有没有办法解决这个问题?


3
当我执行git push -u origin master时,我没有输入任何位置信息
jamescampbell 2015年

感谢您为我指明了正确的方向,我先在这里进行搜索,但由于某种原因,所有相关问题都没有出现类似的问题。
jamescampbell,2015年

19
@垫子我有这个问题。我寻找答案。我找到了这个带有答案的线程。这是它的工作原理。
杰森

11
OP,这是一个很好的问题-非常抱歉社区的大火。显然,回购已经转移了,但是,该怎么办呢?
克里斯,

@Mat,错误消息不会告诉您您需要做什么。直观上来说,如何更改或修改目标位置并不明显,因为它不是命令的一部分。OP希望知道他可以在哪里修改此位置。
Cindeselia

Answers:


277

简单的方法是:

 git remote set-url origin [updated link url https://........git]

另外,如果您喜欢长途旅行,可以:

 git remote rm origin
 git remote add origin [updated link]

更改远程URL的 github文档有更详细的说明。


4
git@github.com:...git如果使用ssh连接,大概需要使用或类似的URL?我的错误消息列出了新的https方案URL,但实际上是git@我实际需要将其设置为来源的URL。git remote show origin会告诉您当前使用的是哪种URL方案。
杰森

23
git remote -v还会显示您设置的网址。
2015年

1
如果可以将您的解决方案交换为第一个=最佳解决方案,那就更好了。在看到较短的解决方案之前,我开始输入您的旧解决方案。
Florian Wendelborn

1
我刚刚完成了@Dodekeract,因为那也是我的反应!
ErichBSchulz

1
@ErichBSchulz感谢您的编辑,希望可以节省人们的时间。干杯。
jamescampbell,2013年
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.