repo-sync

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Repository Sync Skill

仓库同步Skill

Efficiently manage and synchronize 26+ Git repositories with bulk operations, status monitoring, and coordinated commits.
通过批量操作、状态监控和协同提交,高效管理和同步26个以上的Git仓库。

Quick Start

快速开始

bash
undefined
bash
undefined

Check status of all repositories

检查所有仓库的状态

./scripts/repository_sync status all
./scripts/repository_sync status all

Pull latest from all repos

拉取所有仓库的最新代码

./scripts/repository_sync pull all
./scripts/repository_sync pull all

Sync (commit + push) all work repos

同步所有工作仓库(提交+推送)

./scripts/repository_sync sync work -m "End of day sync"
undefined
./scripts/repository_sync sync work -m "当日同步"
undefined

When to Use

适用场景

  • Starting a work session and need to pull latest changes across all repos
  • End of day sync to commit and push all pending changes
  • Checking which repos have uncommitted changes or are behind remote
  • Coordinating branch changes across multiple related repositories
  • Releasing updates across the entire workspace ecosystem
  • 开始工作前,需要拉取所有仓库的最新变更
  • 当日工作结束时,提交并推送所有待处理变更
  • 检查哪些仓库存在未提交变更或落后于远程分支
  • 在多个关联仓库间协调分支变更
  • 在整个工作区生态中发布更新

Prerequisites

前置条件

  • Git installed and configured with SSH keys
  • Access to all repositories in workspace-hub
  • ./scripts/repository_sync
    script available and executable
  • Repository URLs configured in
    config/repos.conf
  • 已安装Git并配置SSH密钥
  • 拥有workspace-hub中所有仓库的访问权限
  • ./scripts/repository_sync
    脚本可用且具备可执行权限
  • 已在
    config/repos.conf
    中配置仓库URL

Overview

概述

This skill enables efficient management of multiple Git repositories in the workspace-hub ecosystem. It provides tools for bulk operations, status monitoring, and coordinated synchronization across all repositories.
该Skill可帮助你高效管理workspace-hub生态中的多个Git仓库,提供批量操作、状态监控和跨仓库协同同步的工具。

Quick Reference

快速参考

Common Commands

常用命令

bash
undefined
bash
undefined

List all repositories

列出所有仓库

./scripts/repository_sync list all
./scripts/repository_sync list all

Check status of all repos

检查所有仓库的状态

./scripts/repository_sync status all
./scripts/repository_sync status all

Pull latest from all repos

拉取所有仓库的最新代码

./scripts/repository_sync pull all
./scripts/repository_sync pull all

Commit and push all repos

提交并推送所有仓库

./scripts/repository_sync sync all -m "Update message"
./scripts/repository_sync sync all -m "更新说明"

Work with specific category

针对特定分类操作

./scripts/repository_sync pull work ./scripts/repository_sync sync personal -m "Personal updates"
undefined
./scripts/repository_sync pull work ./scripts/repository_sync sync personal -m "个人更新"
undefined

Repository Categories

仓库分类

Work Repositories

工作仓库

Business and client projects:
  • digitalmodel
    - Digital model platform
  • energy
    - Energy analysis tools
  • frontierdeepwater
    - Deepwater engineering
  • aceengineer-admin
    - Admin platform
  • aceengineer-website
    - Company website
业务与客户项目:
  • digitalmodel
    - 数字模型平台
  • energy
    - 能源分析工具
  • frontierdeepwater
    - 深水工程
  • aceengineer-admin
    - 管理平台
  • aceengineer-website
    - 公司官网

Personal Repositories

个人仓库

Personal projects and experiments:
  • Side projects
  • Learning repositories
  • Personal tools
个人项目与实验:
  • 副业项目
  • 学习仓库
  • 个人工具

Viewing Categories

查看分类

bash
undefined
bash
undefined

List work repos

列出工作仓库

./scripts/repository_sync list work
./scripts/repository_sync list work

List personal repos

列出个人仓库

./scripts/repository_sync list personal
./scripts/repository_sync list personal

List all repos

列出所有仓库

./scripts/repository_sync list all
undefined
./scripts/repository_sync list all
undefined

Core Operations

核心操作

1. Status Check

1. 状态检查

View the state of all repositories:
bash
./scripts/repository_sync status all
Output indicators:
  • 🟢 Clean: No changes, up to date
  • 🔴 Uncommitted: Has local changes
  • 🟣 Unpushed: Has commits not pushed
  • 🔵 Behind: Remote has updates
  • 🟡 Not cloned: Repository missing locally
查看所有仓库的状态:
bash
./scripts/repository_sync status all
输出标识:
  • 🟢 Clean(干净): 无变更,与远程同步
  • 🔴 Uncommitted(未提交): 存在本地变更
  • 🟣 Unpushed(未推送): 存在未推送的提交
  • 🔵 Behind(落后): 远程有更新
  • 🟡 Not cloned(未克隆): 本地缺少该仓库

2. Pull Operations

2. 拉取操作

Fetch and merge from remote:
bash
undefined
从远程获取并合并代码:
bash
undefined

Pull all repositories

拉取所有仓库

./scripts/repository_sync pull all
./scripts/repository_sync pull all

Pull only work repos

仅拉取工作仓库

./scripts/repository_sync pull work
./scripts/repository_sync pull work

Pull specific repo

拉取指定仓库

./scripts/repository_sync pull digitalmodel
undefined
./scripts/repository_sync pull digitalmodel
undefined

3. Commit Operations

3. 提交操作

Stage and commit changes:
bash
undefined
暂存并提交变更:
bash
undefined

Commit all with default message

使用默认消息提交所有仓库

./scripts/repository_sync commit all
./scripts/repository_sync commit all

Commit with custom message

使用自定义消息提交

./scripts/repository_sync commit all -m "Update dependencies"
./scripts/repository_sync commit all -m "更新依赖"

Commit work repos only

仅提交工作仓库

./scripts/repository_sync commit work -m "Weekly sync"
undefined
./scripts/repository_sync commit work -m "每周同步"
undefined

4. Push Operations

4. 推送操作

Push committed changes to remote:
bash
undefined
将已提交的变更推送到远程:
bash
undefined

Push all repositories

推送所有仓库

./scripts/repository_sync push all
./scripts/repository_sync push all

Push work repos

推送工作仓库

./scripts/repository_sync push work
undefined
./scripts/repository_sync push work
undefined

5. Full Sync (Commit + Push)

5. 完整同步(提交+推送)

Complete synchronization in one command:
bash
undefined
一键完成同步操作:
bash
undefined

Sync all repos

同步所有仓库

./scripts/repository_sync sync all -m "End of day sync"
./scripts/repository_sync sync all -m "当日同步"

Sync work repos

同步工作仓库

./scripts/repository_sync sync work -m "Client updates"
undefined
./scripts/repository_sync sync work -m "客户更新"
undefined

Branch Management

分支管理

List Branches

列出分支

bash
undefined
bash
undefined

Show branches in all repos

显示所有仓库的分支

./scripts/repository_sync branches all
./scripts/repository_sync branches all

Show branches in work repos

显示工作仓库的分支

./scripts/repository_sync branches work
undefined
./scripts/repository_sync branches work
undefined

Fetch Remote Branches

获取远程分支

Track all remote branches locally:
bash
./scripts/repository_sync fetch-branches all
在本地跟踪所有远程分支:
bash
./scripts/repository_sync fetch-branches all

Sync with Main

与主分支同步

Update feature branches with main:
bash
undefined
使用主分支更新功能分支:
bash
undefined

Merge main into current branches

将主分支合并到当前分支

./scripts/repository_sync sync-main all
./scripts/repository_sync sync-main all

Rebase instead of merge

使用变基而非合并

./scripts/repository_sync sync-main all --rebase
undefined
./scripts/repository_sync sync-main all --rebase
undefined

Switch Branches

切换分支

Switch all repos to a specific branch:
bash
undefined
将所有仓库切换到指定分支:
bash
undefined

Switch to main

切换到main分支

./scripts/repository_sync switch all main
./scripts/repository_sync switch all main

Switch to feature branch

切换到功能分支

./scripts/repository_sync switch work feature/new-design
undefined
./scripts/repository_sync switch work feature/new-design
undefined

Configuration

配置

Repository URLs

仓库URL

Configure in
config/repos.conf
:
bash
undefined
config/repos.conf
中配置:
bash
undefined

Repository URL Configuration

仓库URL配置

digitalmodel=git@github.com:username/digitalmodel.git energy=git@github.com:username/energy.git aceengineer-admin=git@github.com:username/aceengineer-admin.git
undefined
digitalmodel=git@github.com:username/digitalmodel.git energy=git@github.com:username/energy.git aceengineer-admin=git@github.com:username/aceengineer-admin.git
undefined

Categories

分类

Defined in
.gitignore
:
bash
digitalmodel/        # Work
energy/              # Work
personal-project/    # Personal
mixed-repo/          # Work, Personal
.gitignore
中定义:
bash
digitalmodel/        # Work
energy/              # Work
personal-project/    # Personal
mixed-repo/          # Work, Personal

Configure Repositories

配置仓库

bash
undefined
bash
undefined

Edit configuration

编辑配置

./scripts/repository_sync config
./scripts/repository_sync config

Refresh repository list

刷新仓库列表

./scripts/repository_sync refresh
undefined
./scripts/repository_sync refresh
undefined

Workflows

工作流

Daily Development Workflow

日常开发工作流

bash
undefined
bash
undefined

Morning: Pull latest

早晨:拉取最新代码

./scripts/repository_sync pull all
./scripts/repository_sync pull all

During day: Work on code...

白天:编写代码...

End of day: Sync everything

下班前:同步所有变更

./scripts/repository_sync sync all -m "$(date +%Y-%m-%d) updates"
undefined
./scripts/repository_sync sync all -m "$(date +%Y-%m-%d) 更新"
undefined

Feature Branch Workflow

功能分支工作流

bash
undefined
bash
undefined

Start feature in all work repos

在所有工作仓库中启动功能开发

./scripts/repository_sync switch work feature/new-feature
./scripts/repository_sync switch work feature/new-feature

Develop across repos...

跨仓库开发...

Keep in sync with main

保持与主分支同步

./scripts/repository_sync sync-main work
./scripts/repository_sync sync-main work

Push feature branches

推送功能分支

./scripts/repository_sync push work
./scripts/repository_sync push work

Return to main

切回主分支

./scripts/repository_sync switch work main
undefined
./scripts/repository_sync switch work main
undefined

Release Workflow

发布工作流

bash
undefined
bash
undefined

Create release branch

创建发布分支

./scripts/repository_sync switch work release/v1.2.0
./scripts/repository_sync switch work release/v1.2.0

Final sync and push

最终同步并推送

./scripts/repository_sync sync work -m "Release v1.2.0 preparation"
./scripts/repository_sync sync work -m "v1.2.0 版本发布准备"

After merge, back to main

合并后切回主分支

./scripts/repository_sync switch work main ./scripts/repository_sync pull work
undefined
./scripts/repository_sync switch work main ./scripts/repository_sync pull work
undefined

Batch Operations

批量操作

Selective Operations

选择性操作

Target specific repositories:
bash
undefined
针对特定仓库操作:
bash
undefined

Multiple specific repos

多个指定仓库

./scripts/repository_sync sync digitalmodel energy -m "Update"
./scripts/repository_sync sync digitalmodel energy -m "更新"

Pattern-based (if supported)

基于匹配模式(若支持)

./scripts/repository_sync sync "ace*" -m "Ace project updates"
undefined
./scripts/repository_sync sync "ace*" -m "Ace项目更新"
undefined

Parallel Execution

并行执行

For faster operations on many repos:
bash
undefined
针对大量仓库提升操作速度:
bash
undefined

Built-in parallelization

内置并行化

./scripts/repository_sync pull all --parallel
./scripts/repository_sync pull all --parallel

Or using xargs

或使用xargs

ls -d */ | xargs -P 4 -I {} git -C {} pull
undefined
ls -d */ | xargs -P 4 -I {} git -C {} pull
undefined

Execution Checklist

执行检查清单

  • Verify SSH authentication (
    ssh -T git@github.com
    )
  • Check repository configuration (
    ./scripts/repository_sync list all
    )
  • Run status check before operations (
    ./scripts/repository_sync status all
    )
  • Review changes in repos with uncommitted work
  • Execute bulk operation with appropriate scope (all/work/personal)
  • Verify operation success with status check
  • Resolve any conflicts or errors reported
  • 验证SSH身份认证(
    ssh -T git@github.com
  • 检查仓库配置(
    ./scripts/repository_sync list all
  • 操作前运行状态检查(
    ./scripts/repository_sync status all
  • 查看存在未提交变更的仓库中的具体修改
  • 针对合适范围(所有/工作/个人)执行批量操作
  • 通过状态检查验证操作成功
  • 解决所有报告的冲突或错误

Error Handling

错误处理

Merge Conflicts

合并冲突

When conflicts occur:
bash
undefined
发生冲突时:
bash
undefined

Status will show conflicts

状态会显示冲突

./scripts/repository_sync status all
./scripts/repository_sync status all

Resolve manually in affected repo

在受影响的仓库中手动解决

cd affected-repo git status
cd affected-repo git status

Fix conflicts...

修复冲突...

git add . git commit -m "Resolve conflicts"
git add . git commit -m "解决冲突"

Continue with other repos

继续处理其他仓库

./scripts/repository_sync sync all
undefined
./scripts/repository_sync sync all
undefined

Stale Branches

陈旧分支

Clean up old branches:
bash
undefined
清理旧分支:
bash
undefined

List stale remote-tracking branches

列出陈旧的远程跟踪分支

git remote prune origin --dry-run
git remote prune origin --dry-run

Prune stale branches

修剪陈旧分支

git remote prune origin
undefined
git remote prune origin
undefined

Recovery

恢复操作

If things go wrong:
bash
undefined
若出现问题:
bash
undefined

Reset to remote state

重置为远程状态

cd repo-name git fetch origin git reset --hard origin/main
cd repo-name git fetch origin git reset --hard origin/main

Or restore from backup

或从备份恢复

git reflog git reset --hard HEAD@{2}
undefined
git reflog git reset --hard HEAD@{2}
undefined

Authentication Issues

身份认证问题

bash
undefined
bash
undefined

Verify SSH key

验证SSH密钥

ssh -T git@github.com
ssh -T git@github.com

Check credential helper

检查凭证助手

git config --global credential.helper
undefined
git config --global credential.helper
undefined

Network Issues

网络问题

bash
undefined
bash
undefined

Test connectivity

测试连通性

git ls-remote origin
git ls-remote origin

Use HTTPS fallback

使用HTTPS作为备选

git remote set-url origin https://github.com/user/repo.git
undefined
git remote set-url origin https://github.com/user/repo.git
undefined

Permission Denied

权限拒绝

bash
undefined
bash
undefined

Check file permissions

检查文件权限

ls -la .git/
ls -la .git/

Fix permissions

修复权限

chmod -R u+rwX .git/
undefined
chmod -R u+rwX .git/
undefined

Metrics & Success Criteria

指标与成功标准

  • Sync Time: All repos synced in < 5 minutes
  • Status Accuracy: 100% accurate status reporting
  • Error Rate: < 1% failed operations
  • Recovery Time: Conflicts resolved within 10 minutes
  • Coverage: All 26+ repos included in sync operations
  • 同步时间: 所有仓库同步完成耗时<5分钟
  • 状态准确性: 状态报告准确率100%
  • 错误率: 操作失败率<1%
  • 恢复时间: 冲突解决耗时<10分钟
  • 覆盖范围: 所有26个以上仓库均包含在同步操作中

Integration Points

集成点

With Workspace CLI

与Workspace CLI集成

bash
undefined
bash
undefined

Launch interactive menu

启动交互式菜单

./scripts/workspace
./scripts/workspace

Navigate: Repository Management → Repository Sync Manager

导航:仓库管理 → 仓库同步管理器

undefined
undefined

With AI Agents

与AI Agents集成

Agents can use repository sync for:
  • Coordinated code changes
  • Cross-repo refactoring
  • Synchronized releases
  • Documentation updates
Agents可使用仓库同步功能完成:
  • 协同代码变更
  • 跨仓库重构
  • 同步发布
  • 文档更新

Related Skills

相关技能

  • workspace-cli - Unified CLI interface
  • compliance-check - Standards verification
  • sparc-workflow - Development methodology
  • workspace-cli - 统一CLI界面
  • compliance-check - 标准验证
  • sparc-workflow - 开发方法论

Windows / Git Bash Workarounds

Windows / Git Bash 解决方案

These are learned from 44+ sync sessions on Windows MINGW64:
这些解决方案来自对Windows MINGW64上44次以上同步会话的总结:

Path Issues

路径问题

  • Trailing spaces in remote filenames prevent checkout — use
    git config core.protectNTFS false
    or skip those files
  • Long paths: enable
    git config --global core.longpaths true
  • Symlinks require admin — use
    git config core.symlinks false
    as fallback
  • 远程文件名末尾有空格会导致无法检出 — 使用
    git config core.protectNTFS false
    或跳过这些文件
  • 长路径:启用
    git config --global core.longpaths true
  • 符号链接需要管理员权限 — 作为备选,使用
    git config core.symlinks false

Line Endings

行尾符

  • Shell scripts must use LF, not CRLF — verify with
    file script.sh
  • Fix:
    dos2unix script.sh
    or
    git config core.autocrlf input
  • Shell脚本必须使用LF,而非CRLF — 使用
    file script.sh
    验证
  • 修复:
    dos2unix script.sh
    git config core.autocrlf input

MINGW Root Path

MINGW根路径

  • while [ "$(pwd)" != / ]
    loops never terminate on MINGW (root is
    /d/
    , not
    /
    )
  • Use
    WORKSPACE_HUB
    env var for path resolution, not runtime
    pwd
    traversal
  • Project key derivation:
    pwd
    /d/workspace-hub/digitalmodel
    D--workspace-hub-digitalmodel
  • 在MINGW中,
    while [ "$(pwd)" != / ]
    循环永远不会终止(根目录是
    /d/
    而非
    /
  • 使用
    WORKSPACE_HUB
    环境变量解析路径,而非运行时
    pwd
    遍历
  • 项目密钥推导:
    pwd
    /d/workspace-hub/digitalmodel
    D--workspace-hub-digitalmodel

Stash Handling

暂存处理

  • Always stash uncommitted changes before pull:
    git stash push -m "pre-sync"
  • After pull,
    git stash pop
    — if conflicts occur, report to user, don't auto-resolve
  • Check stash list:
    git stash list
    to avoid orphaned stashes accumulating
  • 拉取前务必暂存未提交的变更:
    git stash push -m "pre-sync"
  • 拉取后执行
    git stash pop
    — 若发生冲突,需告知用户,不要自动解决
  • 检查暂存列表:
    git stash list
    ,避免积累孤立的暂存内容

Force-Pushed Refs

强制推送的引用

  • When submodule remote was force-pushed:
    git fetch origin && git reset --hard origin/main
  • Detect divergence:
    git rev-list --count HEAD..origin/main
    (behind) and
    ..HEAD
    (ahead)
  • Never rebase diverged branches — always merge or hard-reset after user confirmation
当子模块远程被强制推送时:
git fetch origin && git reset --hard origin/main
  • 检测分歧:
    git rev-list --count HEAD..origin/main
    (落后)和
    ..HEAD
    (超前)
  • 永远不要对分歧的分支执行变基 — 必须在用户确认后执行合并或硬重置

Unregistered Submodules

未注册的子模块

  • Check
    .gitmodules
    before assuming a directory is a submodule
  • git submodule status
    shows registered vs unregistered
在假设某个目录是子模块前,先检查
.gitmodules
  • git submodule status
    会显示已注册和未注册的子模块

.gitignore Conflicts

.gitignore 冲突

  • When remote adds files matching local .gitignore:
    git add -f <file>
    to force-track
当远程添加的文件与本地.gitignore匹配时:
git add -f <file>
强制跟踪

Best Practices

最佳实践

Commit Messages

提交消息

Use consistent format:
[scope] action: description

Examples:
[all] update: Dependency refresh
[work] fix: Security patches
[docs] add: API documentation
使用统一格式:
[范围] 操作: 描述

示例:
[all] update: 依赖更新
[work] fix: 安全补丁
[docs] add: API文档

Frequency

操作频率

  • Pull: Start of each work session
  • Commit: After completing logical units
  • Push: End of work session or before breaks
  • Sync: Daily minimum
  • 拉取: 每个工作会话开始时
  • 提交: 完成逻辑单元后
  • 推送: 工作会话结束时或休息前
  • 同步: 每日至少一次

Verification

验证

Always verify before pushing:
bash
undefined
推送前务必验证:
bash
undefined

Check what will be pushed

检查即将推送的内容

./scripts/repository_sync status all
./scripts/repository_sync status all

Review specific repo changes

查看指定仓库的变更

cd repo-name && git diff origin/main
undefined
cd repo-name && git diff origin/main
undefined

References

参考资料

  • Workspace CLI Documentation
  • Repository Sync Documentation
  • Development Workflow

  • Workspace CLI 文档
  • 仓库同步文档
  • 开发工作流

Version History

版本历史

  • 1.2.0 (2026-02-12): Added MINGW root path, stash handling, divergence detection from /insights analysis of 65+ sync sessions
  • 1.1.0 (2026-01-02): Upgraded to SKILL_TEMPLATE_v2 format - added Quick Start, When to Use, Execution Checklist, Error Handling consolidation, Metrics, Integration Points
  • 1.0.0 (2024-10-15): Initial release with bulk operations, branch management, workflows, error handling, workspace integration
  • 1.2.0 (2026-02-12): 新增MINGW根路径、暂存处理、分歧检测功能,基于对65次以上同步会话的/insights分析
  • 1.1.0 (2026-01-02): 升级为SKILL_TEMPLATE_v2格式 — 新增快速开始、适用场景、执行检查清单、错误处理整合、指标、集成点
  • 1.0.0 (2024-10-15): 初始版本,包含批量操作、分支管理、工作流、错误处理、工作区集成