Git 项目切换到新的远程仓库地址

已存在的 Git 项目切换到新的远程仓库地址,比如你要换成:

复制代码
git@github.com:baoing/test-app.git

步骤如下:

  1. 查看当前的远程仓库地址(可选)
bash 复制代码
git remote -v

你会看到类似:

复制代码
origin git@github.com:old-user/old-repo.git (fetch)
origin git@github.com:old-user/old-repo.git (push)
  1. 修改远程仓库地址为新的:
bash 复制代码
git remote set-url origin git@github.com:baoing/test-app.git
  1. 验证是否修改成功
bash 复制代码
git remote -v

你应该看到:

复制代码
origin  git@github.com:baoing/test-app.git (fetch)
origin  git@github.com:baoing/test-app.git (push)
  1. 推送到新仓库(如果需要)
    比如你想把当前所有分支推送到新仓库:
bash 复制代码
git push -u origin --all

或者只推当前分支:

bash 复制代码
git push -u origin main

(替换 main 为你当前的分支名)

如果你还没有将这个项目提交过任何内容,可以先执行:

bash 复制代码
git add .
git commit -m "Initial commit"
git push -u origin main
相关推荐
Aurora_th2 小时前
浙江海洋大学 资料共享 期末考试卷、课程资料等
git·github
奶茶树5 小时前
【C++】13. C++11新特性【上】
c语言·开发语言·c++·git·github
夏至春来-美美20 小时前
git clone报错
git
拂拉氏20 小时前
【Linux】 开发工具(Makefile、git、cgdb)解析与对于操作系统的基础认识
linux·git·操作系统·makefile·cgdb
番茄不是西红柿kk1 天前
deepseek-harness跨平台桌面端二开项目(附git仓库地址+安装包)
git·agent·codex·deepseek·deepseekharness
leoZ2311 天前
10-Git 仓库蒸馏术:从代码仓库到 OpenClaw 虚拟人-蒸馏工具链
大数据·git·深度学习·神经网络·目标检测·elasticsearch·lstm
fpcc2 天前
工具使用—git diff命令分析说明
git·工具
console.log('npc')2 天前
Git 删除指定提交记录操作指南
git
随风丶飘2 天前
[特殊字符] 告别“update“和“fix bug“——Smart Git Commit LLM 让 AI 帮你写专业的 Git 提交信息
人工智能·git·bug
yanlaifan2 天前
git clone时候指定换行符
git