我只想回到一个干净的工作目录,就像在最后一次提交之后一样。 Git 向我报告了一堆我没有进行过的文件修改,所以我怀疑这与行尾有关。
我已经尝试了所有通常的方法:
git reset --hard
git commit -- .
git stash
git clean -fd
无论我做什么,git status
总是显示相同的文件已被修改。 我应该怎么办? 我在另一个分支中有未提交的更改,因此我不想简单地清除所有内容,而是想“回滚”我的主分支。
编辑:输出
$ git status
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: demo/index.html
# modified: demo/js/app.js
# modified: demo/js/libs/jquery.1.7.1.js
# modified: demo/js/libs/matchMedia.js
# modified: demo/js/libs/modernizr.js
# modified: demo/js/loadr.js
# modified: dist/enquire.js
# modified: src/include/intro.js
#
no changes added to commit (use "git add" and/or "git commit -a")
然后我尝试了建议的方法以及我能找到的其他所有方法:
WickyNilliams at Nick MBA in ~/Repositories/enquire on master*
$ git checkout -- .
WickyNilliams at Nick MBA in ~/Repositories/enquire on master*
$ git reset --hard
HEAD is now at d70fee4 added meta tag to test demo on mobile #10
WickyNilliams at Nick MBA in ~/Repositories/enquire on master*
$ git status
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: demo/index.html
# modified: demo/js/app.js
# modified: demo/js/libs/jquery.1.7.1.js
# modified: demo/js/libs/matchMedia.js
# modified: demo/js/libs/modernizr.js
# modified: demo/js/loadr.js
# modified: dist/enquire.js
# modified: src/include/intro.js
#
no changes added to commit (use "git add" and/or "git commit -a")
正如您所看到的,尽管回滚了,但没有任何更改。
然后我按照建议运行了一个忽略所有空格的diff,像我预料的那样,在忽略空格时似乎没有差异 - 所以我猜想是行结尾符!我该怎么办才能解决这个问题?我已经将autocrlf
设置为true
,但没有效果。
git diff
来查找修改内容吗? - Lily Ballardgit status
输出的相关部分吗? - F.X.