git同时管理以及推送两个仓库
固定语法
git remote add [自定义名] https://github.com/...
可以使用git remote -v
查看本地仓库的关联情况
步骤
- 关联gitee
git remote add gitee https://gitee.com/Han_ruofei/background-management-system
- 关联github
git remote add github Zx-feifei/property-management-system
- 打开.git文件夹下的config文件
会发现该文件下有了刚才添加的信息[remote "gitee"] url = https://gitee.com/Han_ruofei/background-management-system fetch = +refs/heads/*:refs/remotes/gitee/* [remote "github"] url = https://github.com/Zx-feifei/property-management-system fetch = +refs/heads/*:refs/remotes/github/*
- 将本地仓库推送的远程仓库
git push gitee master
git push github master
这种方法较为繁琐,需要多次输入,因此我们可以在config文件中进行配置[remote "gitee"] url = https://gitee.com/Han_ruofei/background-management-system fetch = +refs/heads/*:refs/remotes/gitee/* [remote "github"] url = https://github.com/Zx-feifei/property-management-system fetch = +refs/heads/*:refs/remotes/github/* [remote "all"] url = https://gitee.com/Han_ruofei/background-management-system url = https://github.com/Zx-feifei/property-management-system fetch = +refs/heads/*:refs/remotes/all/*
此时只需要一次 git push all master
即可