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

Git

Git Problem Overview


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

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

So what can I do to fix?

Git Solutions


Solution 1 - Git

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-unchanged against a file that was not listed when executing ls-files -o, and I still received the same error "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.

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.

Solution 2 - Git

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:

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

Solution 3 - Git

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/

Note the forward slash(/) in the end.

Solution 4 - Git

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

Solution 5 - Git

fatal: Unable to mark file 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>

This helped me! :)

Solution 6 - Git

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"

Solution 7 - Git

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.

Solution 8 - Git

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 add myfile.php -f

And that worked for me.

Solution 9 - Git

--assume-unchanged is 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'!

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).

Solution 10 - Git

Make sure you have "web.config" checked in.

If it isn't, you will get this error message.

Solution 11 - Git

One common mistake around using this command is trying to assume either not tracked file or ignored file by git already.

Make sure first that the file is tracked by running

git ls-files | grep relative_path/to/file

If it's not showing your file, then you need to add it first:

git add relative_path/to/file

If this shows your file, or you've already added that file to git, then you should be able to run git assume commands normally:

git update-index --skip-worktree relative_path/to/file

or for folders

git update-index --skip-worktree relative_path/to/folder/

you can check if your file is assumed to be ignored by running

git ls-files -v | grep ^S

The S character represents skipped files.

Solution 12 - Git

So I had this same error when I use this:

git update-index --assume-unchanged appsettings.Development.json

So I changed it to

git update-index --assume-unchanged appsettings.development.json

I actually tried many methods at first but I ended up using this. So I guess its case sensitive

Solution 13 - Git

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

This is what I did to untrack them:

$git reset -- *.orig

if that doesn't work:

$git clean -fd

Solution 14 - Git

Maybe useful for someone. I had the same problem and was no syntax problem, no name with spaces, no path problem, and git reset command didn't work. I was commiting from a folder inside apache www and apache service was stopped. Started again apache service and the error is gone

Solution 15 - Git

I found that sometimes this doesn't work because you've already committed the file to your .gitignore and made a push or pull. You only need to make the push and your file should be ignored on subsequent commits even when you locally modify the file.

Solution 16 - Git

For all future visitors. None of the above resolved my issue. What I realized is the .gitignore file must be placed in the right directory. In my case, once I moved .gitignore to application's root directory the issue was resolved.

Solution 17 - Git

Check if the file to be marked exists and spells correctly, especially the file path and file separator. The file separators of windows system and linux system are in different directions.

Solution 18 - Git

Had the same problem, nothing else worked (my file was tracked, and NOT in gitignore). I realised I copied the file name from terminal output a few lines above, and that made it copy the blank space AFTER the file name. Even though it looks like there is no space, I had a lot of space at the end. So copying just the file path, and keeping it in double qoutes, that helped. I also did a git reset HEAD first.

git update-index --assume-unchanged "app/src/main/java/com/username/projectName/Utils.kt"

Solution 19 - Git

In my case, i was getting the fatal: Unable to mark file error because i had pushed the file to my git repo, so git was not able to find it, first make sure you commit and push the template file that you want to keep in github but do not track it later.

Once pushed, now you can run the command git update-index --skip-worktree YOUR_FILE and modify it without this being tracked

Solution 20 - Git

I had the same issue with cygwin in windows. Giving the full file path

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionKarenView Question on Stackoverflow
Solution 1 - GitDavid MarchelyaView Answer on Stackoverflow
Solution 2 - GitToby BeresfordView Answer on Stackoverflow
Solution 3 - GitSahil SinghView Answer on Stackoverflow
Solution 4 - GitbiswView Answer on Stackoverflow
Solution 5 - GitGrace AloysiusView Answer on Stackoverflow
Solution 6 - GitJon CrowellView Answer on Stackoverflow
Solution 7 - GitmethicalView Answer on Stackoverflow
Solution 8 - GitStepanov MaxView Answer on Stackoverflow
Solution 9 - GitPhilip OakleyView Answer on Stackoverflow
Solution 10 - GitOneSolitaryNoobView Answer on Stackoverflow
Solution 11 - GitAhmed AmrView Answer on Stackoverflow
Solution 12 - GitKazeem QuadriView Answer on Stackoverflow
Solution 13 - GitEdCView Answer on Stackoverflow
Solution 14 - GithernancortesView Answer on Stackoverflow
Solution 15 - GitAkahView Answer on Stackoverflow
Solution 16 - GitAmirView Answer on Stackoverflow
Solution 17 - GitchengwengaoView Answer on Stackoverflow
Solution 18 - GitRachel GreenView Answer on Stackoverflow
Solution 19 - GitMarc AlbrandView Answer on Stackoverflow
Solution 20 - GitSudeepView Answer on Stackoverflow