Remote Already Exists
错误信息
错误: remote 原点 already exists.
快速摘要
remote 使用 name 你 specified (e.g. 原点) 是 already 配置 — 你 cannot 添加它再次.
为什么发生
你 ran git remote 添加原点 <URL> 但原点 already exists
remote 是 auto-配置通过 git 克隆 and 你 tried 到 re-添加它
你是 re-运行设置 script 那个添加 remote
最小示例
✗ 错误代码
git remote add origin https://github.com/user/repo.git # error: remote origin already exists✓ 修复代码
# Update the existing remote URL
git remote set-url origin https://github.com/user/repo.git
# Or remove and re-add
git remote remove origin
git remote add origin https://github.com/user/repo.gitUse git remote 设置-URL 到更改 existing remote's URL, or 移除它首先之前 re-添加.
如何诊断
运行 git remote -v 到 see existing remotes and 它们的 URLs
检查如果 existing remote URL 是正确
验证你是不 re-运行设置 command
如何修复
如果 URL 是错误, 更新它: git remote 设置-URL 原点 <新-URL>
如果你想要不同 remote, use 不同 name: git remote 添加 upstream <URL>
如果你想要到 replace 它: git remote 移除原点 && git remote 添加原点 <URL>
如何预防
检查 git remote -v 之前添加 remotes
Use git 克隆哪个 auto-配置原点