git 删除本地修改 Your local changes to the following files would be overwritten by merge
程序员文章站
2022-07-13 21:12:05
...
如何更新本地的代码,放弃本地的修改,使得和仓库的代码保持一致。
有时候我们把住分支的代码拉下来参考,然后不小心会对代码做一些自己都不知道的修改,等到master分支又有新内容的时候,我们需要去拉新的内容看,结果发现报错了!
当我们在使用git pull origin master
拉取代码的时候,可能会报错
error: Your local changes to the following files would be overwritten by merge:
environment.yml
Please, commit your changes or stash them before you can merge.
Aborting
这是因为我们在本地对代码有所改动了。这时候,我们需要把自己的改动暂时存起来,或者直接删除掉。
使用git status
或者git diff
可以查看当前主机和远程代码的区别。
使用git reset HEAD --hard
将自己的修改都删除掉。
最后在使用git pull origin master
拉取最新代码即可
上一篇: git merge 报错:error: Your local changes to the following files would be overwritten by m
下一篇: git pull 提示错误,Your local changes to the following files would be overwritten by merge
推荐阅读
-
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
-
git pull error: Your local changes to the following files would be overwritten by merge:
-
git merge 报错:error: Your local changes to the following files would be overwritten by m
-
git 删除本地修改 Your local changes to the following files would be overwritten by merge
-
git pull 提示错误,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:
-
Git出现冲突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 提示错误,Your local changes to the following files would be overwritten by merge