Git 中忽略的文件将被合并覆盖

Ignored files in Git would be overwritten by merge

当我拉入我的服务器时,这是我收到的消息:

error: Your local changes to the following files would be overwritten by merge: css/custom.css images/logo.png Please, commit your changes or stash them before you can merge.

但是这两个文件在我的 .gitignore 中被忽略了,像这样:

# general
inc/config.php
css/custom.css
favicon.ico

我做错了什么? 提前致谢!

1) 一些团队成员已经提交了这些文件,因此当您进行 git 拉取时,您将恢复那些已提交的文件更改,并且在您的下一次提交中,这些文件将被视为被忽略的文件。

2) 合并前你需要:

  • 提交您的修改: git add path/to/modified-file 然后 git commit -m "commit message" 最后 git pull

  • 存储您的修改: git stash 然后 git pull 要再次恢复您的修改,请使用 git stash pop