git远程服务器移动,如何更新工作副本配置?

标签 git git-remote

这是我当前的设置

 FDMBA:EnglishStudy willentriken$ git remote -v
 origin <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f4869b9b80b49091829198da849c9b86da9a9180" rel="noreferrer noopener nofollow">[email protected]</a>:~/repos/echo.git (fetch)
 origin <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="790b16160d391d1c0f1c15570911160b57171c0d" rel="noreferrer noopener nofollow">[email protected]</a>:~/repos/echo.git (push)

但是我们将服务器的主机名从 devel.phor.net 更改为其他名称。我可以“重新指向”我的本地 git 存储库以指向这个新服务器地址,而不会丢失我拥有的任何本地提交等吗?

最佳答案

是的,只需使用set-url命令

git remote set-url origin root@newhost:repo/echo.git

可以看到结果

git remote -v
origin root@newhost:repo/echo.git (fetch)
origin root@newhost:repo/echo.git (push)

关于git远程服务器移动,如何更新工作副本配置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13577181/

相关文章:

git - 如何将我当前的项目添加到现有的 GitHub 存储库

Git:为 difftool 和 mergetool 配置模式

git - 为 ‘devDependencies’ 和 ‘dependencies’ 指定不同的 Yarn 安装路径

git - 如何将 `git:` 网址转换为 `http:` 网址

windows - 如何访问 Windows 共享上的 git 存储库?

git - 在 git : understanding it for once and for all 中删除远程分支

git - 使用 Git 将未 merge 的功能分支 merge 到另一个功能分支

Phpstorm 显示所有文件都已更改,但未更改(使用 git)

git - git push 上的 "src refspec does not match"和 "failed to push some refs"错误

git - 本地分支、本地跟踪分支、远程分支和远程跟踪分支有什么区别?