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

Posted blogcxz

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了git pull遇到错误:error: Your local changes to the following files would be overwritten by merge:相关的知识,希望对你有一定的参考价值。

方法1:如果你想保留刚才本地修改的代码,并把git服务器上的代码pull到本地(本地刚才修改的代码将会被暂时封存起来)

git stash
git pull origin master
git stash pop

服务器上的代码更新到了本地,而且你本地修改的代码也没有被覆盖,之后使用add,commit,push 命令即可更新本地代码到服务器了

 

方法2、如果你想完全地覆盖本地的代码,只保留服务器端代码,则直接回退到上一个版本,再进行pull

git reset --hard
git pull origin master

 

以上是关于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: cannot pull with rebase: Your index contains uncommitted changes.

git pull 报错 error: cannot pull with rebase: Your index contains uncommitted changes.

git pull --rebase 报错 error: cannot pull with rebase: Your index contains uncommitted changes.

git pull --rebase 报错 error: cannot pull with rebase: Your index contains uncommitted changes.

git 常见冲突—— git pull遇到报错Your local changes to the following files would be overwritten by merge