Loading...
Loading...
Compare original and translation side by side
| Situation | Example |
|---|---|
| Rebasing on updated main | |
| Merging main into branch | |
| Cherry-picking commits | |
| Pulling with local changes | |
| 场景 | 示例 |
|---|---|
| 基于更新后的主分支变基 | |
| 将主分支合并到当前分支 | |
| 挑选提交 | |
| 本地有修改时拉取代码 | |
Conflict Detected
│
▼
┌─────────────────┐
│ 1. UNDERSTAND │ ← What's conflicting and why?
└────────┬────────┘
│
▼
┌─────────────────┐
│ 2. ANALYZE │ ← Review both versions
└────────┬────────┘
│
▼
┌─────────────────┐
│ 3. RESOLVE │ ← Make informed decision
└────────┬────────┘
│
▼
┌─────────────────┐
│ 4. VERIFY │ ← Tests pass, code works
└────────┬────────┘
│
▼
┌─────────────────┐
│ 5. CONTINUE │ ← Complete the operation
└─────────────────┘Conflict Detected
│
▼
┌─────────────────┐
│ 1. 理解冲突 │ ← 冲突是什么,为什么会发生?
└────────┬────────┘
│
▼
┌─────────────────┐
│ 2. 分析双方代码 │ ← 查看两个版本的代码
└────────┬────────┘
│
▼
┌─────────────────┐
│ 3. 解决冲突 │ ← 做出合理决策
└────────┬────────┘
│
▼
┌─────────────────┐
│ 4. 验证解决方案 │ ← 测试通过,代码可正常运行
└────────┬────────┘
│
▼
┌─────────────────┐
│ 5. 完成操作 │ ← 完成当前的Git操作
└─────────────────┘undefinedundefinedundefinedundefinedundefinedundefined
```typescript
<<<<<<< HEAD
// Your changes
function createUser(data: UserData): User {
return { ...data, id: generateId() };
}
=======
// Their changes (main branch)
function createUser(data: UserData): Promise<User> {
return db.create({ ...data, id: generateId() });
}
>>>>>>> main
```typescript
<<<<<<< HEAD
// 你的修改
function createUser(data: UserData): User {
return { ...data, id: generateId() };
}
=======
// 对方的修改(主分支)
function createUser(data: UserData): Promise<User> {
return db.create({ ...data, id: generateId() });
}
>>>>>>> mainundefinedundefinedundefinedundefined| Question | Consider |
|---|---|
| What was the intent of your change? | Your feature/fix |
| What was the intent of their change? | Their feature/fix |
| Are they mutually exclusive? | Can both coexist? |
| Which is more recent/correct? | Check issue references |
| Do both need to be kept? | Merge the logic |
| 问题 | 考虑因素 |
|---|---|
| 你的修改意图是什么? | 你的功能/修复需求 |
| 对方的修改意图是什么? | 对方的功能/修复需求 |
| 两者是否互斥? | 是否可以共存? |
| 哪个版本更新/更正确? | 查看关联的issue |
| 是否需要保留两者的修改? | 合并逻辑 |
undefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefined// Remove conflict markers
// Combine both changes intelligently
// Result: Keep async from main, add your new validation
async function createUser(data: UserData): Promise<User> {
// Your addition: validation
validateUserData(data);
// Their change: async DB call
return db.create({ ...data, id: generateId() });
}undefinedundefinedundefined
```bash<<<<<<< HEAD ← Remove
======= ← Remove
>>>>>>> main ← Removeundefinedundefined<<<<<<< HEAD ← 删除该行
======= ← 删除该行
>>>>>>> main ← 删除该行undefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefined// main: Function signature changed
function process(data: NewFormat): Result
// yours: Called with old format
process(oldFormatData); // No conflict marker, but broken!undefined// package.json conflict
<<<<<<< HEAD
"dependencies": {
"library": "^2.0.0"
=======
"dependencies": {
"library": "^1.5.0"
>>>>>>> mainpnpm-lock.yamlpnpm install// main分支:函数签名变更
function process(data: NewFormat): Result
// 你的分支:使用旧格式调用
process(oldFormatData); // 没有冲突标记,但代码已损坏!// package.json 冲突
<<<<<<< HEAD
"dependencies": {
"library": "^2.0.0"
=======
"dependencies": {
"library": "^1.5.0"
>>>>>>> mainpnpm-lock.yamlpnpm installundefinedundefinedsrc/services/user.tssrc/utils/validation.tssrc/services/user.tssrc/utils/validation.tsundefinedgit addundefinedgit rebasegit mergegit addgit rebasegit merge