美文网首页
git pull遇到报错:Please commit your

git pull遇到报错:Please commit your

作者: Able7 | 来源:发表于2019-03-09 20:51 被阅读0次

    场景是:
    在公司用办公电脑提交代码到远程仓库之后,回到家里,用自己的笔记本重新拉取远程的更新出现以上错误。家里的笔记本原本也在进行这个项目的开发。

    Please commit your changes or stash them before you merge.
    error: Your local changes to the following files would be overwritten by merge:
    

    意思是我现在的代码会将远程仓库的代码覆盖掉,这个时候当然要以最新的代码为准,不能将远程仓库的代码覆盖啦。
    查询git 的相关文档之后,有如下解决办法:

    git reset  --hard    //将当前的工作目录重置
    git pull origin master //拉取远程更新到本地
    

    另外一种解决办法是:
    保留当前笔记本上写的内容,并将远程仓库的内容更新到本地。

    git stash    //save uncommitted changes。会讲本地所有未提交的修改暂存起来,用于后续恢复。
    git pull origin   master
    git stash pop   //apply last stash and remove it from the list
    

    相关文章

      网友评论

          本文标题:git pull遇到报错:Please commit your

          本文链接:https://www.haomeiwen.com/subject/hmvepqtx.html