Claude 和 ChatGPT 技能比拼之 git rebase

查看 9|回复 0
作者: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
```
您需要登录后才可以回帖 登录 | 立即注册

返回顶部