Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/grails/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用git对文件进行非常奇怪的跟踪_Git - Fatal编程技术网

使用git对文件进行非常奇怪的跟踪

使用git对文件进行非常奇怪的跟踪,git,Git,使用GitVersion1.8.1.msysgit.1,文件被奇怪地跟踪。原因可能是什么 我有一个名为missingFile的git文件 现在我删除这个文件。Git没有错过它。这让我感到奇怪 $ rm missingFile $ ls $ git status # On branch test nothing to commit, working directory clean $ git commit # On branch test nothing to commit, working

使用GitVersion1.8.1.msysgit.1,文件被奇怪地跟踪。原因可能是什么

我有一个名为missingFile的git文件

现在我删除这个文件。Git没有错过它。这让我感到奇怪

$ rm missingFile

$ ls

$ git status
# On branch test
nothing to commit, working directory clean

$ git commit
# On branch test
nothing to commit, working directory clean
但是,当签出文件时,它会神奇地再次出现

$ git checkout missingFile

$ ls
missingFile
而且diff还显示了该文件

$ git diff origin/master
diff --git a/missingFile b/missingFile
new file mode 100644
index 0000000..0633ff0
--- /dev/null
+++ b/missingFile
@@ -0,0 +1,1 @@
+missingFile_content
如何再次获得该文件的标准行为(识别已删除的文件、提交删除、添加文件)?

解决方案 该文件具有skip worktree属性。这一点由中领先的S所揭示

$ git ls-files -v
S missingFile
只需调用
git update index--no skip worktree
即可达到预期效果:

git update-index --no-skip-worktree missingFile
$ git status
# On branch test
# 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:   missingFile
#
no changes added to commit (use "git add" and/or "git commit -a")
git更新索引--无跳过工作树丢失文件
$git状态
#分支测试
#未为提交而暂存的更改:
#(使用“git add…”更新将提交的内容)
#(使用“git签出--…”放弃工作目录中的更改)
#
#修改:丢失文件
#
未向提交添加任何更改(使用“git add”和/或“git commit-a”)

请不要在问题中编辑解决方案,也不要在标题中添加“[已解决]”一词。相反,将其作为答案发布,并(可选)接受它。(是的,对你自己的问题给出答案是完全可以接受的。)@KeithThompson谢谢你的提示。
git update-index --no-skip-worktree missingFile
$ git status
# On branch test
# 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:   missingFile
#
no changes added to commit (use "git add" and/or "git commit -a")