我的git工作目录中有五个文件被git status
显示为已修改状态。当我用git diff
比较它们时,整个文件都被标记为已更改。我设置了core.autocrlf true
,但似乎没有任何效果。
真正的问题出现在我尝试从同事那里拉取变更时。其中一个"已修改"的文件会被合并覆盖,所以我将它们藏起来了。令我惊讶的是,这些更改还在那里。
[dev@carbon:/var/www/html/ourcustomer]$ git stash
Saved working directory and index state WIP on master: ccb93db Merge remote branch 'origin/master'
HEAD is now at ccb93db Merge remote branch 'origin/master'
[dev@carbon:/var/www/html/ourcustomer]$ git status
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: src/ourcustomer/SiteBundle/Resources/public/css/main.css
# modified: src/ourcustomer/SiteBundle/Resources/public/js/main.js
# modified: src/ourcustomer/SiteBundle/Resources/public/js/ourcompany-resize.js
# modified: src/ourcustomer/SiteBundle/Resources/views/Login/languageSelector.html.twig
# modified: src/ourcustomer/SiteBundle/Resources/views/layout.html.twig
#
no changes added to commit (use "git add" and/or "git commit -a")
在这之后,我尝试了git reset --hard HEAD
- 但结果相同。我还尝试了git checkout -- src/ourcustomer/SiteBundle/Resources/public/css/main.css
,但也没有帮助。
这里可能出了什么问题?有没有什么方法可以解决这个问题,还是应该删除并重新克隆整个存储库?
git reset --hard HEAD
。它们是否仍然显示为已修改? - Pedro Rodriguesgit diff -w
不输出任何内容吗?2)您是否在.gitconfig
或.gitattributes
中进行了任何配置,影响了EOF?3)删除索引rm .git/index
和有问题的文件,然后git reset --hard HEAD
仍然没有帮助吗? - Pedro Rodriguesgit diff -b
命令,查看是否只有空格变更。 - Mark Leighton Fisher