git pull报错`error: Your local changes to the following files would be overwritten by merge`

git pull报错error: Your local changes to the following files would be overwritten by merge

  • 问题:git pull报错error: Your local changes to the following files would be overwritten by merge

    git pull报错`error: Your local changes to the following files would be overwritten by merge`_第1张图片

    error: Your local changes to the following files would be overwritten by merge:
            src/pages/login/login_sms.scss                                         
    Please commit your changes or stash them before you merge.                     
    Aborting                     
    Updating 1afa397..4ced4cd  
    
  • 问题原因:远程发生了修改,本地进行了修改,Git不确定应该保存哪一个修改,所以直接就报错了

    PS:下次在进行本地编码时,一定要记得 git pull一下

  • 问题解决:保存本地的修改,拉取最新代码,然后手动处理冲突

    git stash
    git pull origin master
    git stash pop
    
    • git stash:这个命令用于保存当前工作目录中的未提交的更改。你可以将工作目录中的更改保存起来,然后在以后需要的时候再恢复这些更改。
    • git pull origin master:这个命令从远程仓库拉取master分支的最新代码到本地。
    • git stash pop:这个命令用于恢复之前保存的更改。它从stash中取出最近一次保存的更改,并将其应用到当前工作目录。

    git pull报错`error: Your local changes to the following files would be overwritten by merge`_第2张图片

    这是Git为你提供的,关于使用那一部分的代码,就看你自己的选择了

参考资料

  • 解决 error: Your local changes to the following files would be overwritten by merge:XXXX-腾讯云开发者社区-腾讯云 (tencent.com)

你可能感兴趣的:(Bug记录,git,bug)