git中,项目怎么更换远程仓库连接地址

1.需求背景:公司将GitLab的ip地址更改,原来拉下来的项目都需要更换成新的地址,否则无法推送和拉取代码

2.实现过程

2.1 方法1:直接修改远程 URL(推荐)

bash 复制代码
# 查看当前远程仓库地址
git remote -v

# 修改远程仓库 URL
git remote set-url origin <新的仓库地址>

# 例如:
git remote set-url origin https://github.com/username/new-repo.git
# 或 SSH 方式:
git remote set-url origin git@github.com:username/new-repo.git

2.2 方法2:先删除再添加

bash 复制代码
# 删除现有的 origin 远程仓库
git remote rm origin

# 添加新的远程仓库地址
git remote add origin <新的仓库地址>
相关推荐
qq_4260039619 小时前
git切换当前分支到远程分支
git
ON10N1 天前
100% 纯 Vibe Coding,我是怎么用 AI 撸出一个 VS Code 插件的
git·ai编程·visual studio code
Lunar*1 天前
告别臃肿!使用 git-filter-repo 优雅清理 Git 历史记录
git
tq10861 天前
agent 记忆 = markdown + json + git
人工智能·git
何以不说话1 天前
DevOps、Git 和 GitLab
git·gitlab·devops
最最菜的菜鸟1 天前
本地环境通过 SSH 协议访问 GitHub 上的仓库时,SSH 公钥认证失败,配置 Git SSH 密钥
git·ssh·github
无限进步_2 天前
21. 合并两个有序链表 - 题解与详细分析
c语言·开发语言·数据结构·git·链表·github·visual studio
宁静致远20212 天前
STM32CubeMX、MDK(Keil MDK)、git、vscode等工具中统一编码设置(UTF-8),确保中文支持,避免乱码问题
git·vscode·stm32
love530love2 天前
Windows 多 Git 环境冲突:一个环境变量优先级引发的血案
人工智能·windows·git·环境变量·scoop
无限进步_2 天前
面试题 02.04. 分割链表 - 题解与详细分析
c语言·开发语言·数据结构·git·链表·github·visual studio