git 上传git库时报错,提示有冲突

具体报错信息如下:

error: Your local changes to the following files would be overwritten by merge:
        .idea/workspace.xml
Please commit your changes or stash them before you merge.
Aborting
Updating c89a38f..649ce27

翻译如下:

错误:您对以下文件的本地更改将被合并覆盖:

.idea/ workspace.xml。

请在合并前提交更改或隐藏更改。

中止

更新649ce27 c89a38f ..

解决方法:

如果希望保留生产服务器上所做的改动,仅仅并入新配置项, 处理方法如下:

$ git stash

$ git pull

$ git stash pop

然后可以使用git diff -w +文件名 来确认代码自动合并的情况.

反过来,如果希望用代码库中的文件完全覆盖本地工作版本. 方法如下:

git reset --hard

git pull


其中git reset是针对版本,如果想针对文件回退本地修改,使用

git checkout HEAD file/to/restore 


原文地址:https://www.cnblogs.com/APeng2019/p/10719437.html