brycewang-stanford/Auto-Empirical-Research-Skills / skills/33-Galaxy-Dawn-claude-scholar/skills/git-workflow
git-workflow
VerifiedThis skill should be used when the user asks to "create git commit", "manage branches", "follow git workflow", "use Conventional Commits", "handle merge conflicts", or asks about git branching strategies, version control best practices, pull request workflows. Provides comprehensive Git workflow guidance for team collaboration.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 11.7 KB |
| examples/commit-messages.txt | markdown | 1.0 KB |
| examples/workflow-commands.sh | script | 2.9 KB |
| references/advanced-usage.md | markdown | 7.6 KB |
| references/branching-strategies.md | markdown | 4.0 KB |
| references/collaboration.md | markdown | 2.2 KB |
| references/commit-conventions.md | markdown | 3.3 KB |
| references/conflict-resolution.md | markdown | 2.6 KB |
| references/gitignore-guide.md | markdown | 4.2 KB |
| references/merge-strategies.md | markdown | 3.0 KB |
references/conflict-resolution.md
View on GitHub# 冲突处理详解
## 识别冲突
当 Git 无法自动合并时,会标记冲突:
```
<<<<<<< HEAD
// 当前分支的代码
const name = '张三'
=======
// 要合并的分支的代码
const name = '李四'
>>>>>>> feature/user-management
```
## 解决冲突步骤
### 1. 查看冲突文件
```bash
git status
```
### 2. 手动编辑文件,解决冲突
打开冲突文件,找到冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`),手动编辑选择保留的内容或合并两者。
### 3. 标记已解决
```bash
git add <file>
```
### 4. 完成合并
```bash
# 对于 merge 冲突
git commit
# 对于 rebase 冲突
git rebase --continue
```
## 冲突处理策略
### 保留当前分支版本
```bash
git checkout --ours <file>
git add <file>
```
### 保留传入分支版本
```bash
git checkout --theirs <file>
git add <file>
```
### 放弃合并
```bash
# 放弃 merge
git merge --abort
# 放弃 rebase
git rebase --abort
```
## 预防冲突的最佳实践
1. **及时同步代码** - 每天开始工作前拉取最新代码
2. **小步提交** - 频繁提交小的改动
3. **功能模块化** - 不同功能在不同文件中实现
4. **沟通协作** - 避免同时修改同一文件
## 常见冲突场景
### 场景1:同一文件不同位置修改
这种情况 Git 通常能自动合并,无需人工干预。
### 场景2:同一行不同修改
需要手动决定保留哪个版本或合并两者。
### 场景3:文件重命名
Git 通常能智能识别,但如果一个分支重命名而另一个分支修改内容,可能需要手动处理。
### 场景4:二进制文件冲突
对于图片、PDF 等二进制文件,需要决定保留哪个版本:
```bash
# 保留当前分支的版本
git checkout --ours image.png
# 或保留传入分支的版本
git checkout --theirs image.png
```
## 冲突解决工具
### 使用 merge 工具
```bash
# 配置合并工具
git config --global merge.tool vimdiff
git config --global mergetool.prompt false
# 使用合并工具
git mergetool
```
### 使用 diff 工具
```bash
# 查看详细差异
git diff --ours
git diff --theirs
git diff --base
```
## Rebase 冲突特殊处理
Rebase 时冲突会逐个提交出现,处理方式:
```bash
git rebase develop
# 冲突1 -> 解决 -> git add -> git rebase --continue
# 冲突2 -> 解决 -> git add -> git rebase --continue
# ...
# 直到完成
```
如果某一步想跳过:
```bash
git rebase --skip
```
如果整体想放弃:
```bash
git rebase --abort
```
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |