我的repo似乎被锁定在这种状态下,我无法摆脱。即使我重置到HEAD~1,我仍然收到有关此单个文件已修改的通知。使用'add'和'checkout'均未起作用。我的core.autocrlf和core.safecrlf都未设置(为空)。
请参见下文:
$ git --version
git version 1.7.9.6 (Apple Git-31.1)
$ git status
# 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: a_file_name.cpp
以下命令(分别运行)没有影响:$ git checkout -- a_file_name.cpp
$ git reset a_file_name.cpp
$ git add a_file_name.cpp
$ git reset --hard
$ git clean -n
<nothing>
$ git clean -f
<nothing>
$ git status
# 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: a_file_name.cpp
它继续进行......
我做错了什么?
回应 @Don 的建议(git rm)并没有变化,但是这就是情况:
$ git rm
error: 'a_file_name.cpp' has local modifications
(use --cached to keep the file, or -f to force removal)
$ git rm -f a_file_name.cpp
rm 'a_file_name.cpp'
$ git status
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# deleted: a_file_name.cpp
#
# Changes not staged for commit:
# (use "git add/rm <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# deleted: a_file_name.cpp
#
$ git commit -m"tmp"
[master 2a9e054] tmp
1 file changed, 174 deletions(-)
delete mode 100644 a_file_name.cpp
$ git status
# Your branch is ahead of 'origin/master' by 1 commit.
#
# Changes not staged for commit:
# (use "git add/rm <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# deleted: a_file_name.cpp
#
基本上回到原点。
autocrlf
,safecrlf
,.gitattributes
等)? - ellothethgit checkout -- a_file_name.cpp
时会发生什么?同时确保在运行此命令时与该文件处于同一目录中。 - Code-Apprentice# modified: sub-dir/a_file_name.cpp
。如果您可以重现此问题,则应记录错误。Git绝对不应该这样做。 - CB Bailey