git修改某个远端服务器的地址的方式以及4种remote(git remote set-url origin xxx、git remote -v)

假设本地有1个远端仓库,默认一般叫origin,原来对应的git url是:git@xxx.git

shell 复制代码
# 查看方式:
git remote -v

# 修改方式:
git地址url指定远程仓库:(常用)
git remote set-url origin git@new.server.com:username/repo.git

或者https方式:
git remote set-url origin https://new.server.com/path/to/repo.git

或者是本地的其他仓库当做remote时候:
git remote set-url origin file:///path/to/repo.git

或者甚至是亚节点:
git remote set-url origin path/to/repo.git

另外上面的origin可能不同的仓库在本地的servername不一样做动态修改就行,比如:

c 复制代码
git remote set-url myprivsrv git@new.server.com:username/repo.git

其他:

  • 所有的各种表达远程的仓库,本质都是.git的配置,只要有这个配置便可以配置
  • 通过这种seturl可以灵活的修改本地的远端仓库,甚至这里的远端其实实际有可能在本地
  • 结合本地的git作为远端可以灵活做一些工程最佳实践
  • 本地可以支持多个remote的server名字,如果想修改就使用这种方式
相关推荐
_codemonster9 小时前
.git文件夹里所有文件详解
git
01杭呐10 小时前
一次错误分支合并导致 `master` 变脏的排查与修复
git
_codemonster10 小时前
git本地以及github查看历史版本、版本回退
git·github
周小码21 小时前
10分钟搭建私有Git服务器:Soft Serve实战
运维·服务器·git
梅塔文·欧帕西安卡琼1 天前
git的底层原理详解
git
待什么青丝1 天前
【git的摸鱼技巧】之工欲善其事
git·elasticsearch·搜索引擎
2601_961194021 天前
高中英语教资资料推荐|科三大题背诵和教学设计模板
git·开源·github·开源软件·开源协议·ossinsight
ting94520001 天前
InsForge Backend Branching 后端全链路 Git 式分支技术原理、架构实现与底层源码剖析
人工智能·git·elasticsearch·架构
程序猿阿伟1 天前
《扣子如何让OpenClaw技能开发提速》
人工智能·git·github
摇滚侠1 天前
IDEA 创建 Java 项目 推送到远程 Git 仓库
java·git·intellij-idea