V2EX 2小时前
解决Git Rebase冲突保留master版本
index_new5.html
../../../zaker_core/zaker_tpl_static/wap/tpl_guoji1.html

 

本文介绍了在Git rebase过程中出现冲突时,如何丢弃指定分支上的文件,保留master分支上的版本,并给出相应的命令。

问题:
sh<br />我在 branchA 上执行 git rebase master ,然后出现冲突文件 a,b ,我想要丢弃 branchA 中的 a,b ,保留 master 中的 a,b 。我该怎么做,给出命令。<br />

Claude4.5 免费版(网页):
sh<br /># 对于文件 a 和 b ,使用 master 的版本<br />git checkout --ours a<br />git checkout --ours b<br /><br /># 标记冲突已解决<br />git add a b<br /><br /># 继续 rebase<br />git rebase --continue<br />

ChatGPT 免费版(网页):
sh<br /># 对文件 a 使用 master (即目标分支)的版本<br />git checkout --theirs -- a<br /><br /># 对文件 b 使用 master (即目标分支)的版本<br />git checkout --theirs -- b<br /><br /># 标记解决冲突<br />git add a b<br /><br /># 继续 rebase<br />git rebase --continue<br /><br /><br />

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

Fish AI Reader

Fish AI Reader

AI辅助创作,多种专业模板,深度分析,高质量内容生成。从观点提取到深度思考,FishAI为您提供全方位的创作支持。新版本引入自定义参数,让您的创作更加个性化和精准。

FishAI

FishAI

鱼阅,AI 时代的下一个智能信息助手,助你摆脱信息焦虑

联系邮箱 441953276@qq.com

相关标签

Git Rebase 冲突解决 版本管理 命令行
相关文章