前言
编辑器会把没有添加到忽略名单的文件自动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 <file>..." to unstage)
new file: build.zip
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
deleted: build.zip
原来是这个zip包被添加到暂存区了,执行命令
git reset
即把当前HEAD中的内容恢复到暂存区,这是再pull就正常了。
附图
更多git相关知识请移步:https://blog.youkuaiyun.com/daoke_li/article/details/104295741