gitsync-rust

git仓库同步工具

项目简介

gitsync-rust 是一款使用 Rust 开发的 Git 多仓库同步工具,支持 Repo 配置模式与 GitLab API 分组同步模式。

命令结构

gitsync-rust [全局参数] <子命令>

全局参数

  • --log-file <PATH>:日志文件路径,默认 gitsync.log
  • --verbose:控制台输出详细日志,默认 false
gitsync-rust --log-file ./logs/gitsync.log --verbose repo pull --config config.json --workspace ./workspace

子命令一:Repo 模式

支持:clone / pull / push / clear

  • -c, --config <PATH>:配置文件路径,默认 config.json
  • -w, --workspace <PATH>:本地工作区目录,默认当前目录 .
  • --delete-remote-on-reject:仅 repo push 有效;push 被拒绝时先删远端目标分支再重试,默认 false
# 克隆
gitsync-rust repo clone --config config.json --workspace ./workspace

# 拉取
gitsync-rust repo pull -c config.json -w ./workspace

# 推送
gitsync-rust repo push -c config.json -w ./workspace

# 被拒绝时删除远端分支后重试(高风险)
gitsync-rust repo push -c config.json -w ./workspace --delete-remote-on-reject

# 清理
gitsync-rust repo clear -c config.json -w ./workspace

子命令二:GitLab 同步模式

gitsync-rust gitlab sync [参数]

必填参数

  • --local <URL>:源 GitLab 地址
  • --local-token <TOKEN>:源端访问令牌
  • --remote <URL>:目标 GitLab 地址
  • --remote-token <TOKEN>:目标端访问令牌
  • --push-url <URL>:实际推送地址

可选参数(默认值)

  • --local-group <a,b>:源端分组,逗号分隔;不填则同步全部
  • --remote-group <a,b>:目标分组映射;不填默认同名
  • --remote-parent-group <name>:目标父分组
  • --mode <mirror|branch>:同步模式,默认 mirror
  • --dry-run <true|false>:预演模式,默认 false
  • --force-push <true|false>:是否强制推送,默认 true
  • --ignore-branches <a,b>:忽略分支(仅 branch 模式)
  • --allow-branches <a,b>:允许分支(仅 branch 模式)
  • --max-repo-size-mb <N>:仓库大小上限(MB)
  • --retry-failed-only <true|false>:仅重试失败项目,默认 false
  • --failed-projects-file <PATH>:失败清单文件,默认 .gitsync-failed-projects.json
  • --recreate-project-on-reject:push 拒绝时删除并重建目标项目后重试一次,默认 false(高风险)
gitsync-rust gitlab sync \
  --local https://source.gitlab.local \
  --local-token <SOURCE_TOKEN> \
  --remote https://target.gitlab.local \
  --remote-token <TARGET_TOKEN> \
  --push-url https://target.gitlab.local \
  --mode mirror \
  --dry-run true

使用建议

  • 首次使用先 --dry-run true 验证映射和权限
  • 先小规模仓库测试,再全量同步
  • 涉及删除重建/删分支参数时先在测试环境验证
← 返回下载中心