git update-index --assume-unchanged 返回“致命的无法标记文件”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12920652/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 14:47:14  来源:igfitidea点击:

git update-index --assume-unchanged returns "fatal unable to mark file"

git

提问by Karen

I am having the same problem as the OP on thispost, but I don't understand the answer marked as correct (I don't see that it explains how to fix the situation)

我遇到了与这篇文章中的 OP 相同的问题,但我不明白标记为正确的答案(我没有看到它解释了如何解决这种情况)

I do this and get this error:

我这样做并收到此错误:

$ git update-index --assume-unchanged web.config
fatal: Unable to mark file web.config
  1. The file IS added to the repository

  2. It is NOT in .git/info/exclude

  3. It is NOT in .gitignore(it was, but I took it out, then forced web.config to be added using git add -f web.config, committed, and pushed those changes to the repo)

  4. When I do Git ls-files -o it is NOT there

  1. 该文件已添加到存储库

  2. 它不在 .git/info/exclude

  3. .gitignore不在(它是,但我把它拿出来,然后强制使用git add -f web.config、提交并将这些更改推送到存储库中添加 web.config )

  4. 当我执行 Git ls-files -o 时它不存在

So what can I do to fix?

那么我能做些什么来修复?

采纳答案by David Marchelya

I was having the same problem as you, and had followed the same four steps that you indicated above, and had the same results. This included the fact that my file was listed when executing git ls-files -o. However in my case, I also tried executing git update-index --assume-unchangedagainst a file that was not listed when executing ls-files -o, and I still received the same error "fatal: Unable to mark file".

我和你遇到了同样的问题,并且按照你上面指出的相同的四个步骤,得到了相同的结果。这包括我的文件在执行git ls-files -o. 但是,就我而言,我也尝试git update-index --assume-unchanged对执行时未列出的文件执行ls-files -o,但仍然收到相同的错误“ fatal: Unable to mark file”。

I thought that perhaps it was a bug, and downloaded the latest version of git, but this did not help.

我认为可能是一个错误,并下载了最新版本的 git,但这并没有帮助。

What I finally realized is that this command is case sensitive! This includes the full path and file name.After updating path to the directory so that the full path was specified with proper casing, the command executed properly.

我终于意识到这个命令是区分大小写的!这包括完整路径和文件名。更新目录路径以便使用正确的大小写指定完整路径后,命令正确执行。

Note that this was with Git for Windows, so you're results may vary with other platforms.

请注意,这是针对 Windows 的 Git,因此您的结果可能因其他平台而异。

回答by Toby Beresford

I was having the same issue on a Mac. Case-sensitivity wasn't an issue for me - the problem was I needed to reset my git first:

我在 Mac 上遇到了同样的问题。区分大小写对我来说不是问题 - 问题是我需要先重置我的 git:

Problem:

问题:

 git update-index --assume-unchanged index.php
 fatal: Unable to mark file index.php

Solution:

解决方案:

git reset HEAD
Unstaged changes after reset:
M   index.php
git update-index --assume-unchanged index.php

回答by Sahil Singh

In my case the tree I was marking was a directory, and not a file as in you case, and I was missing the forward slash after its name.

在我的例子中,我标记的树是一个目录,而不是像你这样的文件,我在它的名字后面缺少正斜杠。

Incorrect -

不正确——

git update-index --assume-unchanged directory-name

Correct -

正确的 -

git update-index --assume-unchanged directory-name/

Notethe forward slash(/) in the end.

注意最后的正斜杠(/)。

回答by Grace Aloysius

fatal: Unable to mark file Localization/el-GR.js

致命:无法标记文件 Localization/el-GR.js

What you can do is:

你可以做的是:

  1. Move to the correct path where the file is present in your local (in GITBASH)
  2. Update the index $git update-index --assume-unchanged <file name>
  1. 移动到文件在本地(在 GITBASH 中)存在的正确路径
  2. 更新索引 $git update-index --assume-unchanged <file name>

This helped me! :)

这对我有帮助!:)

回答by bisw

Make sure the file is added to git repo, if not add the file in git repo and then try it will work.

确保将文件添加到 git repo,如果没有将文件添加到 git repo 中,然后尝试它会起作用。

回答by Jon Crowell

If your path has spaces, you may get this error even if you have the casing right.

如果您的路径有空格,即使您的大小写正确,您也可能会收到此错误。

This results in the "fatal" error:

这会导致“致命”错误:

git update-index --assume-unchanged code/Solution Files/WebEssentials-Settings-json

To fix it, simply add quotes around the path.

要修复它,只需在路径周围添加引号。

git update-index --assume-unchanged "code/Solution Files/WebEssentials-Settings-json"

回答by methical

My Problem was, that I tried the command with a * wildcard assuming it would be recursive, but it wasn't.

我的问题是,我尝试了带有 * 通配符的命令,假设它是递归的,但事实并非如此。

So what I did was

所以我所做的是

$ git reset HEAD
Unstaged changes after reset: 
M   .gradle/1.9/taskArtifacts/cache.properties.lock
M   .gradle/1.9/taskArtifacts/fileHashes.bin
M   .gradle/1.9/taskArtifacts/fileSnapshots.bin
M   .gradle/1.9/taskArtifacts/outputFileStates.bin
M   .gradle/1.9/taskArtifacts/taskArtifacts.bin

executing

执行

$ git update-index --assume-unchanged .gradle/1.9/taskArtifacts/*

worked for me then and didn't result in OPs and my problem.

当时对我来说有效,并没有导致 OP 和我的问题。

回答by EdC

I had this problem when I was trying to untrack *.orig files.

我在尝试取消跟踪 *.orig 文件时遇到了这个问题。

This is what I did to untrack them:

这就是我为取消跟踪他们所做的:

$git reset -- *.orig

if that doesn't work:

如果这不起作用:

$git clean -fd

回答by Stepanov Max

In my case, I tried to use any of the methods above, but no luck.

就我而言,我尝试使用上述任何方法,但没有成功。

After many attempts, I just thought to add my file to index through.

经过多次尝试,我只是想将我的文件添加到索引中。

git add myfile.php

Git refused this action but he advised me to make it forcibly.

Git 拒绝了这个动作,但他建议我强制执行。

git add myfile.php -f

And that worked for me.

这对我有用。

回答by Philip Oakley

--assume-unchangedis about slow file systems, and a users promise that Git doesn't need to check this file, as Git can assume its unchanged. But some command still do check and produce 'surprise'!

--assume-unchanged是关于慢速文件系统,用户承诺 Git 不需要检查这个文件,因为 Git 可以假设它没有改变。但是一些命令仍然会检查并产生“惊喜”!

Do not use on files which change.

不要在更改的文件上使用。

Sorry to be the bringer of that news (I have a patch in process to change that documentation).

很抱歉成为该消息的提供者(我正在准备更改该文档的补丁)。