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名字,如果想修改就使用这种方式
相关推荐
leoZ2312 小时前
10-Git 仓库蒸馏术:从代码仓库到 OpenClaw 虚拟人-蒸馏工具链
大数据·git·深度学习·神经网络·目标检测·elasticsearch·lstm
fpcc15 小时前
工具使用—git diff命令分析说明
git·工具
console.log('npc')15 小时前
Git 删除指定提交记录操作指南
git
随风丶飘16 小时前
[特殊字符] 告别“update“和“fix bug“——Smart Git Commit LLM 让 AI 帮你写专业的 Git 提交信息
人工智能·git·bug
yanlaifan16 小时前
git clone时候指定换行符
git
小小安于乱20 小时前
解决IDEA的git插件pull代码冲突但右下角不提示消息问题
java·git·intellij-idea
ITKEY_1 天前
git 命令行操作回退到指定版本
git
New_Horizons6661 天前
Git 操作(使用git-commit-template)
git
慕容引刀1 天前
或许你真的需要这个Git神器:让团队提交文案终于对齐了
人工智能·git·vscode·自然语言处理·github
jjh+++(求关注版)1 天前
git-命令速查清单
git