repo-sync
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRepository Sync Skill
仓库同步Skill
Efficiently manage and synchronize 26+ Git repositories with bulk operations, status monitoring, and coordinated commits.
通过批量操作、状态监控和协同提交,高效管理和同步26个以上的Git仓库。
Quick Start
快速开始
bash
undefinedbash
undefinedCheck 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 "当日同步"
undefinedWhen 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
- script available and executable
./scripts/repository_sync - Repository URLs configured in
config/repos.conf
- 已安装Git并配置SSH密钥
- 拥有workspace-hub中所有仓库的访问权限
- 脚本可用且具备可执行权限
./scripts/repository_sync - 已在中配置仓库URL
config/repos.conf
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
undefinedbash
undefinedList 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 "个人更新"
undefinedRepository Categories
仓库分类
Work Repositories
工作仓库
Business and client projects:
- - Digital model platform
digitalmodel - - Energy analysis tools
energy - - Deepwater engineering
frontierdeepwater - - Admin platform
aceengineer-admin - - Company website
aceengineer-website
业务与客户项目:
- - 数字模型平台
digitalmodel - - 能源分析工具
energy - - 深水工程
frontierdeepwater - - 管理平台
aceengineer-admin - - 公司官网
aceengineer-website
Personal Repositories
个人仓库
Personal projects and experiments:
- Side projects
- Learning repositories
- Personal tools
个人项目与实验:
- 副业项目
- 学习仓库
- 个人工具
Viewing Categories
查看分类
bash
undefinedbash
undefinedList 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
undefinedCore Operations
核心操作
1. Status Check
1. 状态检查
View the state of all repositories:
bash
./scripts/repository_sync status allOutput 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
undefinedPull 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
undefined3. Commit Operations
3. 提交操作
Stage and commit changes:
bash
undefined暂存并提交变更:
bash
undefinedCommit 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 "每周同步"
undefined4. Push Operations
4. 推送操作
Push committed changes to remote:
bash
undefined将已提交的变更推送到远程:
bash
undefinedPush 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
undefined5. Full Sync (Commit + Push)
5. 完整同步(提交+推送)
Complete synchronization in one command:
bash
undefined一键完成同步操作:
bash
undefinedSync 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 "客户更新"
undefinedBranch Management
分支管理
List Branches
列出分支
bash
undefinedbash
undefinedShow 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
undefinedFetch Remote Branches
获取远程分支
Track all remote branches locally:
bash
./scripts/repository_sync fetch-branches all在本地跟踪所有远程分支:
bash
./scripts/repository_sync fetch-branches allSync with Main
与主分支同步
Update feature branches with main:
bash
undefined使用主分支更新功能分支:
bash
undefinedMerge 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
undefinedSwitch Branches
切换分支
Switch all repos to a specific branch:
bash
undefined将所有仓库切换到指定分支:
bash
undefinedSwitch 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
undefinedConfiguration
配置
Repository URLs
仓库URL
Configure in :
config/repos.confbash
undefined在中配置:
config/repos.confbash
undefinedRepository 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
undefineddigitalmodel=git@github.com:username/digitalmodel.git
energy=git@github.com:username/energy.git
aceengineer-admin=git@github.com:username/aceengineer-admin.git
undefinedCategories
分类
Defined in :
.gitignorebash
digitalmodel/ # Work
energy/ # Work
personal-project/ # Personal
mixed-repo/ # Work, Personal在中定义:
.gitignorebash
digitalmodel/ # Work
energy/ # Work
personal-project/ # Personal
mixed-repo/ # Work, PersonalConfigure Repositories
配置仓库
bash
undefinedbash
undefinedEdit configuration
编辑配置
./scripts/repository_sync config
./scripts/repository_sync config
Refresh repository list
刷新仓库列表
./scripts/repository_sync refresh
undefined./scripts/repository_sync refresh
undefinedWorkflows
工作流
Daily Development Workflow
日常开发工作流
bash
undefinedbash
undefinedMorning: 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) 更新"
undefinedFeature Branch Workflow
功能分支工作流
bash
undefinedbash
undefinedStart 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
undefinedRelease Workflow
发布工作流
bash
undefinedbash
undefinedCreate 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
undefinedBatch Operations
批量操作
Selective Operations
选择性操作
Target specific repositories:
bash
undefined针对特定仓库操作:
bash
undefinedMultiple 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项目更新"
undefinedParallel Execution
并行执行
For faster operations on many repos:
bash
undefined针对大量仓库提升操作速度:
bash
undefinedBuilt-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
undefinedls -d */ | xargs -P 4 -I {} git -C {} pull
undefinedExecution 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
undefinedStatus 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
undefinedStale Branches
陈旧分支
Clean up old branches:
bash
undefined清理旧分支:
bash
undefinedList stale remote-tracking branches
列出陈旧的远程跟踪分支
git remote prune origin --dry-run
git remote prune origin --dry-run
Prune stale branches
修剪陈旧分支
git remote prune origin
undefinedgit remote prune origin
undefinedRecovery
恢复操作
If things go wrong:
bash
undefined若出现问题:
bash
undefinedReset 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}
undefinedgit reflog
git reset --hard HEAD@{2}
undefinedAuthentication Issues
身份认证问题
bash
undefinedbash
undefinedVerify SSH key
验证SSH密钥
ssh -T git@github.com
ssh -T git@github.com
Check credential helper
检查凭证助手
git config --global credential.helper
undefinedgit config --global credential.helper
undefinedNetwork Issues
网络问题
bash
undefinedbash
undefinedTest connectivity
测试连通性
git ls-remote origin
git ls-remote origin
Use HTTPS fallback
使用HTTPS作为备选
git remote set-url origin https://github.com/user/repo.git
undefinedgit remote set-url origin https://github.com/user/repo.git
undefinedPermission Denied
权限拒绝
bash
undefinedbash
undefinedCheck file permissions
检查文件权限
ls -la .git/
ls -la .git/
Fix permissions
修复权限
chmod -R u+rwX .git/
undefinedchmod -R u+rwX .git/
undefinedMetrics & 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
undefinedbash
undefinedLaunch interactive menu
启动交互式菜单
./scripts/workspace
./scripts/workspace
Navigate: Repository Management → Repository Sync Manager
导航:仓库管理 → 仓库同步管理器
undefinedundefinedWith 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 or skip those files
git config core.protectNTFS false - Long paths: enable
git config --global core.longpaths true - Symlinks require admin — use as fallback
git config core.symlinks false
- 远程文件名末尾有空格会导致无法检出 — 使用或跳过这些文件
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: or
dos2unix script.shgit config core.autocrlf input
- Shell脚本必须使用LF,而非CRLF — 使用验证
file script.sh - 修复:或
dos2unix script.shgit config core.autocrlf input
MINGW Root Path
MINGW根路径
- loops never terminate on MINGW (root is
while [ "$(pwd)" != / ], not/d/)/ - Use env var for path resolution, not runtime
WORKSPACE_HUBtraversalpwd - Project key derivation: →
pwd→/d/workspace-hub/digitalmodelD--workspace-hub-digitalmodel
- 在MINGW中,循环永远不会终止(根目录是
while [ "$(pwd)" != / ]而非/d/)/ - 使用环境变量解析路径,而非运行时
WORKSPACE_HUB遍历pwd - 项目密钥推导:→
pwd→/d/workspace-hub/digitalmodelD--workspace-hub-digitalmodel
Stash Handling
暂存处理
- Always stash uncommitted changes before pull:
git stash push -m "pre-sync" - After pull, — if conflicts occur, report to user, don't auto-resolve
git stash pop - Check stash list: to avoid orphaned stashes accumulating
git stash list
- 拉取前务必暂存未提交的变更:
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: (behind) and
git rev-list --count HEAD..origin/main(ahead)..HEAD - 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 before assuming a directory is a submodule
.gitmodules - shows registered vs unregistered
git submodule status
在假设某个目录是子模块前,先检查
.gitmodules- 会显示已注册和未注册的子模块
git submodule status
.gitignore Conflicts
.gitignore 冲突
- When remote adds files matching local .gitignore: to force-track
git add -f <file>
当远程添加的文件与本地.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
undefinedCheck 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
undefinedcd repo-name && git diff origin/main
undefinedReferences
参考资料
- 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): 初始版本,包含批量操作、分支管理、工作流、错误处理、工作区集成