文章目录
  1. 1. git仓库备份
  2. 2. git一次提交到两个仓库

git仓库备份

需求很简单
oschina上做主要的代码,在coding做代码备份

  1. 首先在oschinacoding上分别创建项目test_git_mirroe
  2. oschinaclone代码git clone https://git.oschina.net/openks/test_git_mirroe.git
  3. 跳转到项目目录cd test_git_mirroe
  4. 添加coding的远程仓库git remote add coding https://git.coding.net/zhuyangxing/test_git_mirroe.git
  5. 提交coding做镜像代码git push --mirror coding
  6. 以后在test_git_mirroe上提交的代码都提交到oschina
  7. 想要在coding上同步就执行git push --mirror coding即可

git一次提交到两个仓库

修改.git文件夹下的config文件
fetch下添加想要提交的其他git路径即可

1
2
3
4
[remote "origin"]
  url = https://git.oschina.net/openks/test_git_mirroe.git
  fetch = +refs/heads/*:refs/remotes/origin/*
  url = new git url

文章目录
  1. 1. git仓库备份
  2. 2. git一次提交到两个仓库