【git冲突解决】: Please commit your changes or stash them before you merge.

刚刚使用 git pull 命令拉取代码时候,遇到了这样的问题:

error: Your local changes to the following files would be overwritten by merge:
code/b2bstore/site/src/main/webapp/pc/src/themes/ac-b2bpc/order/order-confirm.vue
Please commit your changes or stash them before you merge.

  

这是由于远程库中的更改与本地的更改有冲突

git的提示已经非常明确了,告诉我们要么把我们的更新进行commit要么就先stash本地更新。

我是通过这种方式解决的:

   git add.
  git commit -m "订单详情"
  git pull 先拉取代码
  git push 最后提交你写了的代码

  

或者:用stash也行

git stash
git pull
git stash pop

 接下来diff一下此文件看看自动合并的情况,并作出相应的修改。

git stash:备份当前的工作区,从最近一次提交中读取相关内容,让工作区保持和上一次提交的内容一致。同时,将工作区的内容保存到git栈中。

git stash pop:从git栈中读取最近一次保存的内容,恢复工作区的相关内容。由于可能存在多个stash的内容,所以用栈来管理,pop会从最近一个stash中读取内容并恢复到工作区。

git stash list:显示git栈内的所有备份,可以利用这个列表来决定从那个地方恢复。

git stash clear:情况git栈。

  

原文地址:https://www.cnblogs.com/wufenfen/p/13804456.html