logo
0
0
Login

mpgrm - 多平台 Git 仓库管理器

一个轻量级的多平台 Git 仓库迁移工具,支持在不同代码托管平台之间选择性地转移分支和标签。

🔥 核心功能

  • 跨平台仓库迁移:在不同 Git 代码托管平台之间无缝迁移仓库
  • 选择性迁移:支持仅迁移特定分支和标签
  • 发布管理:上传、下载、创建和同步发布版本及附件
  • 批量操作:支持在组织或用户级别进行批量仓库同步
  • 多平台支持:兼容 GitHub、Gitee、Gitea 和 cnb.cool

🚀 安装指南

从源代码安装

  • 确保您已安装 Go 1.23+
  • 克隆仓库并编译
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"

💻 使用示例

credential

轻松管理仓库凭证,随时推送

# 基本用法 # 通过命令行直接指定仓库 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

推送仓库 (push)

将指定分支和标签从源仓库推送到目标仓库

# 基本用法 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

管理发布版本 (releases)

上传发布文件

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

管理仓库 (repo)

列出仓库

# 列出组织的所有仓库 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

repo 和 target-repo 使用指南

CloneURL 根据结尾字符确定它指向的是组织还是仓库

组织 URL(以 / 结尾)

  • 表示组织路径。
  • 仓库名称应附加在后面以生成完整的仓库 URL。
  • 目前不支持没有尾部 / 的 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

  • 指向域根或用户主页的 URL。

  • 通常仅作参考;不隐含任何仓库。

  • 示例:

https://github.com/ https://github.com https://cnb.cool https://cnb.cool/

仓库 URL(不以 / 结尾或以 .git 结尾)

https://github.com/org/repo.git https://cnb.cool/org1/child1

⚠️ 注意: 尾部 / 是区分组织 URL 和仓库 URL 的关键。 组织 URL 需要附加仓库名称,而仓库 URL 已经完整。

🤝 贡献指南

  1. Fork 本仓库
  2. 创建您的特性分支 (git checkout -b feature/AmazingFeature)
  3. 提交您的更改 (git commit -m 'Add some AmazingFeature')
  4. 推送到分支 (git push origin feature/AmazingFeature)
  5. 打开 Pull Request

About

一款轻量级的多平台 Git 仓库迁移工具,支持在远程仓库之间选择性地迁移分支和标签。

428.00 KiB
0 forks0 stars1 branches1 TagREADMEApache-2.0 license
mpgrmsame-named
Language
Go98.5%
Makefile1.1%
Dockerfile0.4%