在github中重命名repo时出错,"remote:此存储库已移动.请使用新位置"

jam*_*ell 153 git

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

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

jam*_*ell 233

简单的方法是:

 git remote set-url origin [updated link url https://........git]
Run Code Online (Sandbox Code Playgroud)

或者,如果您喜欢漫长的道路:

 git remote rm origin
 git remote add origin [updated link]
Run Code Online (Sandbox Code Playgroud)

更改远程URL的 github文档更详细.

  • `git remote -v`也会显示你设置的网址. (18认同)
  • 大概你需要使用`git@github.com:... git`或类似的URL,如果使用ssh连接?我的错误消息列出了新的`https`方案URL,但它实际上需要设置为原始的`git @`URL.`git remote show origin`会告诉你当前正在使用的URL方案. (4认同)
  • 不要忘记添加新存储库 URL 的上游。第一次推送时,您会收到错误消息。只需使用`git push --set-upstream origin master`。 (2认同)

inf*_*era 45

检查当前的一个:

  git remote -v
Run Code Online (Sandbox Code Playgroud)

然后改变它:

  git remote set-url origin https://github.com/YOUR-USERNAME/YOUR-REPO.git
Run Code Online (Sandbox Code Playgroud)


Eng*_*nny 5

这是我找到的答案的升级。检查当前的:

git remote -v
Run Code Online (Sandbox Code Playgroud)

使用上面的命令,您将得到类似的结果

origin  https://github.com/YOUR-USERNAME/YOUR-REPO (fetch)
origin  https://github.com/YOUR-USERNAME/YOUR-REPO (push)
Run Code Online (Sandbox Code Playgroud)

请注意,这是不同之处,它可能并不总是起源。

您可以根据发现的内容编写命令。因此,如果它是原点,那么您将其更改为:

git remote set-url origin https://github.com/YOUR-USERNAME/YOUR-REPO
Run Code Online (Sandbox Code Playgroud)

如果它在上游,您可以将其更改为:

git remote set-url upstream https://github.com/YOUR-USERNAME/YOUR-REPO
Run Code Online (Sandbox Code Playgroud)