You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何解决Git分支合并中yarn.lock的版本冲突问题

解决yarn.lock冲突并保留本地包版本的操作步骤
  • 切换到你的branch_A分支(若当前不在该分支):
    git checkout branch_A
    如有未提交的本地变更,先暂存:git stash(后续恢复可执行git stash pop)

  • 直接保留当前分支(branch_A)的yarn.lock版本以解决冲突:
    git checkout --ours yarn.lock
    该命令会让Git舍弃来自main分支的yarn.lock变更,完全使用你本地分支的文件版本,对应你自己安装的包版本。

  • 验证依赖状态,确保所有包能正常安装:
    yarn install

  • 提交冲突解决方案:
    git add yarn.lock
    git commit -m "Resolve yarn.lock conflict: retain local package versions"

  • 推送更新到远程branch_A分支:
    git push origin branch_A

内容的提问来源于stack exchange,提问作者ZombiePie

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.13 21:32:01