我无法摆脱我的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
Run Code Online (Sandbox Code Playgroud)
以下命令(单独运行)没有任何影响:
$ 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
Run Code Online (Sandbox Code Playgroud)
它继续......
回复@ 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
#
Run Code Online (Sandbox Code Playgroud)
几乎回到了sq.1
小智 6
一种对我有用的方法是:
重新创建我删除的文件。
git add path/filename
git rm --cached path/filename
删除文件
git add .
git commit --amend # if not on an already pushed branch.
运行任何命令时,请确保您位于与该文件相同的目录中git。或者,您可以对与命令一起使用的文件使用相对或绝对路径git。的输出git status 应指示文件所在的子目录。我觉得很奇怪,你在这里发布的输出没有显示这一点。