git设置多仓库代码管理

一般我们 git clone 来下载仓库代码,下载下来的代码有时候会多仓库源代码处理。

多个远程仓库分别处理

  1. 先查看当前项目所有远程仓库信息
git remote -v
  1. 查看源仓库信息
git remote show orgin

看别的仓库也一样,git remote show [remote]


  1. 为项目添加其他远程仓库 git remote add [shortName] [url]
git remote add otherRemote http://otherRemote.com/code.git
  1. 拉取指定仓库代码 git pull [remote] [branch]
git pull orgin
  1. 推送代码至指定仓库 git push [remote] [branch]
git push origin



  1. 删除远程仓库 git remote rm [remote]
git remote rm otherRemote
  1. 修改远程仓库本地名字 git remote rename [oldName] [newName]
git remote rename oldName newName

多个远程仓库共同处理

我们只需要为项目同样源名称添加仓库地址就可以用同样的操作处理代码

git remote set-url --add origin http://addOrigin.com/code.git

语法 git remote set-url --add [remote] [addUrl] 此时提交代码,git push 就可以同时推送到已添加的远程仓库了


相关git学习

经验分享 程序员 微信小程序 职场和发展