区块链中文技术社区

更换Git子模块的仓库地址

更换子模块地址

  1. 修改 .gitmodules
[submodule "libs/foo"]
    path = libs/foo
    url  = https://github.com/old-org/foo.git

改成:

[submodule "libs/foo"]
    path = libs/foo
    url  = https://github.com/new-org/foo.git
  1. 同步配置
git submodule sync
  1. 更新子模块
git submodule update --init --recursive
  1. 更新仓库
git add .gitmodules
git commit -m "chore: update submodule foo url"
git push

更换主仓库地址

  1. 查看当前远端
git remote -v

你会看到类似:

origin  https://github.com/old-org/project.git (fetch)
origin  https://github.com/old-org/project.git (push)
  1. 修改 origin 地址
git remote set-url origin https://github.com/new-org/project.git

验证

git remote -v
  1. 推送到新组织(第一次建议加 -u)
git push -u origin main
# 或
git push -u origin master

当前页面是本站的「Google AMP」版。查看和发表评论请点击:完整版 »