git代码库pull报错:error: Your local changes to the following files would be overwritten by merge

前言

编辑器会把没有添加到忽略名单的文件自动add到git的暂存区。

起因

某次build后打了个zip压缩包放在根目录下,被自动add了,但commit时把勾打掉没有提交。第二天来把这个zip包手动删除后,pull代码时就报错了:

From http://*.*.*.*/cd-h5/customrecipe

* branch master -> FETCH_HEAD

error: Your local changes to the following files would be overwritten by merge:

build.zip

解决

通过 git status 查看

Changes to be committed:

(use "git restore --staged ..." to unstage)

new file: build.zip

Changes not staged for commit:

(use "git add/rm ..." to update what will be committed)

(use "git restore ..." to discard changes in working directory)

deleted: build.zip

原来是这个zip包被添加到暂存区了,执行命令

git reset

即把当前HEAD中的内容恢复到暂存区,这是再pull就正常了。

附图

git代码库pull报错:error: Your local changes to the following files would be overwritten by merge_第1张图片

更多git相关知识请移步:https://blog.csdn.net/daoke_li/article/details/104295741

 

你可能感兴趣的:(代码管理)