Claude 和 ChatGPT 技能比拼之 git rebase

20 小时 31 分钟前
 SGL
问题:
```sh
我在 branchA 上执行 git rebase master ,然后出现冲突文件 a,b ,我想要丢弃 branchA 中的 a,b ,保留 master 中的 a,b 。我该怎么做,给出命令。
```

Claude4.5 免费版(网页):
```sh
# 对于文件 a 和 b ,使用 master 的版本
git checkout --ours a
git checkout --ours b

# 标记冲突已解决
git add a b

# 继续 rebase
git rebase --continue
```

ChatGPT 免费版(网页):
```sh
# 对文件 a 使用 master (即目标分支)的版本
git checkout --theirs -- a

# 对文件 b 使用 master (即目标分支)的版本
git checkout --theirs -- b

# 标记解决冲突
git add a b

# 继续 rebase
git rebase --continue


```

ChatGPT Plus(网页 Thinking 模式):
```sh
# 处于 rebase 冲突状态时:
git checkout --theirs -- a b # 选用“theirs”,在 rebase 中指的是 master 的版本
git add a b # 标记冲突已解决
git rebase --continue

```
498 次点击
所在节点    程序员
0 条回复

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/1167359

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX