




现有仓库同步





未来代码的同步
方案一:增加 remote 源
git remote add <name> <url>git remote add gitee ``[git@github.com](mailto:git@github.com "git@github.com")``:hua1995116/mmt.git
git push origin // 提交到 github git push gitee // 提交到 gitee
方案二:增加 push 源
git remote rm gitee
git remote set-url --add origin git@github.com:hua1995116/mmt.git
git push origin
npm i -g mmt mmt import https://gitee.com/hua1995116/mmt-practices/raw/master/mmt-export-gitee.json // 进入到你想要添加命令的目录 mmt run gitee // 每个原有 github 仓库无脑运行这个命令就可以

方案三: 使用github action
# 通过 Github actions, 在 Github 仓库的每一次 commit 后自动同步到 Gitee 上
name: gitee-sync
on:
  push:
    branches:
      - master
jobs:
  repo-sync:
    env:
      dst_key: ${{ secrets.GITEE_PRIVATE_KEY }}
      dst_token: ${{ secrets.GITEE_TOKEN }}
      gitee_user: ${{ secrets.GITEE_USER }}
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          persist-credentials: false
      - name: sync github -> gitee
        uses: Yikun/hub-mirror-action@master
        if: env.dst_key && env.dst_token && env.gitee_user
        with:
          # 必选,需要同步的 Github 用户(源)
          src: 'github/${{ github.repository_owner }}'
          # 必选,需要同步到的 Gitee 用户(目的)
          dst: 'gitee/${{ secrets.GITEE_USER }}'
          # 必选,Gitee公钥对应的私钥,https://gitee.com/profile/sshkeys
          dst_key: ${{ secrets.GITEE_PRIVATE_KEY }}
          # 必选,Gitee对应的用于创建仓库的token,https://gitee.com/profile/personal_access_tokens
          dst_token:  ${{ secrets.GITEE_TOKEN }}
          # 如果是组织,指定组织即可,默认为用户 user
          # account_type: org
          # 直接取当前项目的仓库名
          static_list: ${{ github.event.repository.name }}
          # 还有黑、白名单,静态名单机制,可以用于更新某些指定库
          # static_list: 'repo_name,repo_name2'
          # black_list: 'repo_name,repo_name2'
          # white_list: 'repo_name,repo_name2'
- 
GITEE_USER, 例如我的 gitee hua1995116
- 
GITEE_PRIVATE_KEY,获取方法(如果已有,直接设置) – Gitee公钥对应的私钥[2]- 
新建 private key 方法: 
- 
生成 SSH 公钥[3] 
- 
将 SSH 公钥添加到 Gitee 公钥[4] 
- 
同时将公钥添加到 Github 项目的 secrets 中; 
 
- 
- 
GITEE_TOKEN,获取方法 – Gitee对应的用于创建仓库的token[5]新建 token 方法:- 
点击上面的链接并登录 Gitee, 点击“生成新令牌”, 
- 
添加描述,比如用处 – Github 仓库同步到 Gitee; 
- 
权限默认全选,点击提交,显示出生成的 token 值;(注意保存,需要填到 Github 的 secrets 中) 
 
- 
|  | 2.能够控制提交源 | 2.提交简单 | 2.提交和原来无异 | 
|  |  |  |  | 
|  |  |  |  | 
























