Gitpull遇到错误:error: Your local changes to the following files would be overwritten by merge:
Posted cqlb
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Gitpull遇到错误:error: Your local changes to the following files would be overwritten by merge:相关的知识,希望对你有一定的参考价值。
这种情况下,如何保留本地的修改同时又把远程的合并过来呢?
首先取决于你是否想要保存本地修改。(是 /否)
是
别急我们有如下三部曲
- git stash
- git pull origin master
- git stash pop
git stash的时候会把你本地快照,然后git pull 就不会阻止你了,pull完之后这时你的代码并没有保留你的修改。惊了! 别急,我们之前好像做了什么?
STASH
这时候执行git stash pop你去本地看会发现发生冲突的本地修改还在,这时候你该commit push啥的就悉听尊便了。
否
既然不想保留本地的修改,那好办。直接将本地的状态恢复到上一个commit id 。然后用远程的代码直接覆盖本地就好了。
- git reset --hard
- git pull origin master
以上是关于Gitpull遇到错误: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报错:error: You have not concluded your merge (MERGE_HEAD exists).
git 常见冲突—— git pull遇到报错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出现冲突error: Your local changes to the following files would be overwritten by merge: xxx/...