持续更新中…
场景1:小项目强行pull remote分支并覆盖掉本地分支
背景:当队友push上新的代码,而我莫名其妙修改了一点没有用的地方导致pull下来出错时。我tm直接覆盖本地
问题描述
比如下面出现的错误
1. warning: fetch updated the current branch head.
fast-forwarding your working tree from commit
error: Your local changes to the following files would be overwritten by merge:
Please commit your changes or stash them before you merge.
Aborting
fatal: Cannot fast-forward your working tree.
After making sure that you saved anything precious from
原因分析:
主要原因
: pull 下来的文件与自己已经修改但是还没有commit的文件有冲突
解决方案:
git fetch --all
git reset --hard origin/main