一个Git项目多个仓库

方法一:(使用 “git remote add 仓库名” 命令)--推荐

  第一个仓库(默认仓库)

  git remote add origin https://github.com......
  git push -u origin master

  第二个仓库(着色部分便是第二仓库)

git remote add newRepository https://github.com......
git push -u newRepository master
取消关联时:git remote remove newRepository
git remote
newRepository
origin

git remote -v
newRepository   https://github.com/lixy-github/newRepository.git (fetch)
newRepository   https://github.com/lixy-github/newRepository.git (push)
origin  http://....com:5678/gitbucket/git/Li.XY/Pride.git (fetch)
origin  http://....com:5678/gitbucket/git/Li.XY/Pride.git (push)

  可以看到两个仓库状态,但是要push两次。

 

方法二:(使用 git remote set-url” 命令)  

git remote set-url --add newRepository https://git.hub.com/......
git remote -v
newRepository   https://github.com/lixy-github/newRepository.git (push)
origin  http://....com:5678/gitbucket/git/Li.XY/Pride.git (fetch)
origin  http://....com:5678/gitbucket/git/Li.XY/Pride.git (push)

  可以看到远程仓库有两个 push 地址,这种方法的好处是每次只需要push一次就可以了。

 

方法三:

  打开 .git/config 找到 [remote "github"],添加对应的 url 即可,效果如下。这种方法其实和方法二是一样的。

[remote "github"]
    url =http://....com:5678/gitbucket/git/Li.XY/Pride.git
    fetch = +refs/heads/*:refs/remotes/github/*
    url = https://github.com/lixy-github/newRepository.git 

 

方法二和方法三在push的时候比较方便,但是只有1个拉取地址,而方法一有2个拉取地址和2个push地址,所以个人推荐方法一。

转载于:https://www.cnblogs.com/lxynn/p/10298640.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值