一个轻量级的多平台 Git 仓库迁移工具,支持在不同代码托管平台之间选择性地转移分支和标签。
git clone https://cnb.cool/zhiqiangwang/mpgrm
cd mpgrm && make build
编译后的可执行文件将位于项目根目录
复制环境变量示例文件
cp .env.example .env
编辑 .env 文件并根据您的平台添加相应的认证信息
# CNB 平台用户名(CNB 没有个人仓库,只有组织。 # 此值用作 "个人仓库" 标识符) CNB_USERNAME="cnb" # CNB 平台访问令牌 CNB_TOKEN="token_cnb_abcdef123456" # Gitea 平台用户名 GITEA_USERNAME="gitea" # Gitea 平台访问令牌 GITEA_TOKEN="a1b2c3d4e5f6g7h8i9j0klmnopqrstuvwx" # Gitee 平台用户名 GITEE_USERNAME="gitee" # Gitee 平台访问令牌 GITEE_TOKEN="z9y8x7w6v5u4t3s2r1q0ponmlkjihgfedcba" # GitHub 用户名 GITHUB_USERNAME="github" # GitHub 个人访问令牌 GITHUB_TOKEN="ghp_FAKE1234567890abcdefABCDEFabcdef"
轻松管理仓库凭证,随时推送
# 基本用法 # 通过命令行直接指定仓库 URL。 # 默认行为(是否从环境变量读取)由 --use-env 控制。 mpgrm credential show --repo https://github.com/username/source-repo.git # 指定仓库 URL 并明确禁用从环境变量读取。 # --use-env=false 表示命令将仅使用通过 --repo 提供的 URL。 mpgrm credential show --use-env=false --repo https://github.com/username/source-repo.git
将指定分支和标签从源仓库推送到目标仓库
# 基本用法
mpgrm push --repo https://github.com/username/source-repo.git --target-repo https://gitee.com/username/target-repo.git
# 选择性推送特定分支和标签
mpgrm push --repo https://github.com/username/source-repo.git --target-repo https://gitee.com/username/target-repo.git --branches main,develop --tags v1.0.0,v1.1.0
# 指定工作区目录
mpgrm push --repo https://github.com/username/source-repo.git --target-repo https://gitee.com/username/target-repo.git --workspace /path/to/workspace
mpgrm releases upload --repo https://github.com/username/repo.git --tags v1.0.0 --files path/to/file1.zip,path/to/file2.tar.gz
mpgrm releases download --repo https://github.com/username/repo.git --tags v1.0.0,v1.1.0
mpgrm releases create --repo https://github.com/username/repo.git
mpgrm releases sync --repo https://github.com/username/source-repo.git --target-repo https://gitee.com/username/target-repo.git --tags v1.0.0,v1.1.0
# 列出组织的所有仓库
mpgrm repo list --repo https://github.com/organization/
# 列出用户的所有仓库
mpgrm repo list --repo https://github.com
# 列出并克隆组织的所有仓库
mpgrm repo clone --repo https://github.com/<organization>/
# 列出并克隆用户的所有仓库
mpgrm repo clone --repo https://github.com/<username>
# 同步组织的所有仓库
mpgrm repo sync --repo https://github.com/organization/ --target-repo https://gitee.com/organization/
# 同步用户的所有仓库
mpgrm repo sync --repo https://github.com --target-repo https://gitee.com
CloneURL 根据结尾字符确定它指向的是组织还是仓库。
/ 的 URL(例如 https://github.com/org)。https://github.com/org/ -> org
https://cnb.cool/org1/ -> org1
https://cnb.cool/org1/child1/ -> org1/child1
https://cnb.cool/org1/child1/child2/ -> org1/child1/child2
指向域根或用户主页的 URL。
通常仅作参考;不隐含任何仓库。
示例:
https://github.com/
https://github.com
https://cnb.cool
https://cnb.cool/
https://github.com/org/repo.git
https://cnb.cool/org1/child1
⚠️ 注意: 尾部
/是区分组织 URL 和仓库 URL 的关键。 组织 URL 需要附加仓库名称,而仓库 URL 已经完整。
git checkout -b feature/AmazingFeature)git commit -m 'Add some AmazingFeature')git push origin feature/AmazingFeature)