Skip to content

brycewang-stanford/Auto-Empirical-Research-Skills / skills/33-Galaxy-Dawn-claude-scholar/skills/git-workflow

git-workflow

Verified

This 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.

references/merge-strategies.md

View on GitHub
# 合并策略详解

## Merge vs Rebase

| 特性     | Merge                      | Rebase                   |
| :------- | :------------------------- | :----------------------- |
| 历史记录 | 保留完整历史,创建合并提交 | 线性历史,不创建合并提交 |
| 适用场景 | 公共分支、需要保留历史     | 私有分支、保持历史清晰   |
| 冲突处理 | 一次性处理所有冲突         | 逐个提交处理冲突         |
| 推荐用法 | 合并到主分支               | 同步上游代码             |

## 使用建议

### 功能分支同步 develop:使用 rebase

```bash
git checkout feature/user-management
git rebase develop
```

### 功能分支合并到 develop:使用 merge --no-ff

```bash
git checkout develop
git merge --no-ff feature/user-management
```

### develop 合并到 master:使用 merge --no-ff

```bash
git checkout master
git merge --no-ff develop
```

### 禁止在公共分支上 rebase

```bash
# ❌ 危险操作
git checkout develop
git rebase feature/xxx  # 会改写公共历史
```

## Fast-Forward vs No-Fast-Forward

### Fast-Forward 合并(不创建合并提交)

```bash
git merge feature/xxx
```

```
# A---B---C  (master)
#          \
#           D---E  (feature)
# 结果: A---B---C---D---E  (master)
```

### No-Fast-Forward 合并(创建合并提交)

```bash
git merge --no-ff feature/xxx
```

```
# A---B---C---------M  (master)
#          \       /
#           D---E    (feature)
```

**项目约定**:合并功能分支时使用 `--no-ff`,保留分支历史信息。

## Squash 合并

将多个提交压缩成一个:

```bash
git checkout develop
git merge --squash feature/user-management
git commit -m "feat(user): 添加用户管理功能"
```

### 适用场景

- 功能分支有太多琐碎提交
- 想要保持主分支历史清晰
- 不需要保留开发过程中的细节

### Squash vs Merge --no-ff

| 策略        | 优点                     | 缺点                     | 适用场景               |
| :---------- | :----------------------- | :----------------------- | :--------------------- |
| merge --no-ff | 保留完整历史和开发过程   | 历史可能比较复杂         | 功能分支、重要功能     |
| squash      | 历史清晰,一个提交一个功能 | 丢失开发过程信息         | 小功能、实验性功能     |
| rebase      | 线性历史,易于理解       | 改写历史,可能引起问题   | 个人分支、同步上游     |

## Rebase 高级用法

### 交互式 Rebase

```bash
# 编辑最近5个提交
git rebase -i HEAD~5
```

在编辑器中可以使用以下命令:
- `pick` - 保留该提交
- `reword` - 修改提交消息
- `edit` - 修改提交内容
- `squash` - 合并到前一个提交
- `drop` - 删除该提交

### Rebase 时解决冲突

```bash
git rebase develop
# 出现冲突后,编辑文件解决冲突
git add <file>
git rebase --continue
# 如果想放弃 rebase
git rebase --abort
```
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: 472kUpdated Claude CodeCodexVerifiedInstall
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: 323kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 323kUpdated Claude CodeCodexVerifiedInstall
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 availableStars: 323kUpdated Claude CodeCodexVerifiedInstall