sync
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSync Skill
同步Skill
Quick git synchronization with remote repository.
与远程仓库快速进行Git同步。
Usage
使用方法
Commands
命令
bash
/sync # Pull from origin main
/sync develop # Pull from origin develop
/sync upstream # Pull from upstream main (forks)bash
/sync # 从origin main拉取
/sync develop # 从origin develop拉取
/sync upstream # 从upstream main拉取(适用于复刻仓库)Korean Triggers
韩文触发词
- "동기화"
- "원격에서 가져와"
- "풀 받아"
- "동기화"(同步)
- "원격에서 가져와"(从远程获取)
- "풀 받아"(拉取)
Workflow
工作流程
1. Pre-sync Check
1. 同步前检查
bash
git statusIf working directory has uncommitted changes:
Options:
- Stash: → sync →
git stashgit stash pop - Commit first: Suggest using
/cp - Discard: Only if user confirms with
git checkout .
bash
git status如果工作区存在未提交的变更:
选项:
- 暂存:→ 同步 →
git stashgit stash pop - 先提交:建议使用命令
/cp - 丢弃:仅当用户确认后执行
git checkout .
2. Fetch and Pull
2. 获取并拉取
Default (origin main):
bash
git pull origin mainWith rebase (cleaner history):
bash
git pull --rebase origin main默认操作(origin main):
bash
git pull origin main使用变基(更整洁的提交历史):
bash
git pull --rebase origin main3. Report Results
3. 结果报告
After successful sync:
Synced with origin/main
- 3 commits pulled
- Files changed: 5
- No conflicts同步成功后:
已与origin/main同步
- 拉取了3次提交
- 变更文件数:5
- 无冲突Handling Conflicts
冲突处理
If merge conflicts occur:
- List conflicting files
- Offer to help resolve
- After resolution: →
git add <files>git commit
如果出现合并冲突:
- 列出冲突文件
- 提供冲突解决协助
- 解决后执行:→
git add <files>git commit
Common Scenarios
常见场景
Fork Workflow
复刻仓库工作流程
bash
undefinedbash
undefinedAdd upstream if not exists
如果不存在则添加upstream远程仓库
git remote add upstream <original-repo-url>
git remote add upstream <original-repo-url>
Sync with upstream
与upstream同步
git fetch upstream
git merge upstream/main
undefinedgit fetch upstream
git merge upstream/main
undefinedDiverged Branches
分支分歧处理
If local and remote have diverged:
bash
undefined如果本地与远程分支出现分歧:
bash
undefinedOption 1: Merge (default)
选项1:合并(默认)
git pull origin main
git pull origin main
Option 2: Rebase (cleaner)
选项2:变基(更整洁)
git pull --rebase origin main
git pull --rebase origin main
Option 3: Reset (destructive, ask user)
选项3:重置(破坏性操作,需询问用户)
git fetch origin
git reset --hard origin/main
undefinedgit fetch origin
git reset --hard origin/main
undefinedError Handling
错误处理
| Error | Solution |
|---|---|
| "Uncommitted changes" | Stash or commit first |
| "Merge conflict" | Help resolve conflicts |
| "Remote not found" | Check |
| 错误 | 解决方案 |
|---|---|
| "未提交的变更" | 暂存或先提交 |
| "合并冲突" | 协助解决冲突 |
| "未找到远程仓库" | 检查 |