git update-index --assume-unchanged returns error

16,305

Solution 1

Is it added to the repository, not in .git/info/exclude and not on .gitignore?

If the answer is yes to either of those, then the file is not in the repository and this is the reason for the error.

Try git ls-files -o and see if the file is there. It should not be.

Solution 2

You are running git update-index --assume-unchanged because you have files that are checked into the repository but you want to ignore local edits.

As Pedro points out, the file that's giving you the error is not checked into the repository. (It shows up in git ls-files -o which means it's untracked.)

This may come about because you're trying to ignore an entire directory recursively like so:

find ./folder/ -type f | xargs git update-index --assume-unchanged

But not only are files in that folder modified, new files have been created. (e.g. by a build script.)

If you are certain that you want to ignore all modified files, you can do so with this command:

git ls-files -m | xargs git update-index --assume-unchanged

But watch out. Be aware that messing with --assume-unchanged can be a pain.

Consider re-working things so those files don't need to be in the repo at all. Then you can add them to your .gitignore and delete them from the repository with git rm --cached.

If you can keep the files out of both the repo and the users working directories, that may be ideal. For example, if the files are created as part of building, you could create a static library instead of having each developer run the build process locally.

Share:
16,305

Related videos on Youtube

Sreeram Ravinoothala
Author by

Sreeram Ravinoothala

Updated on June 04, 2022

Comments

  • Sreeram Ravinoothala
    Sreeram Ravinoothala almost 2 years

    git update-index --assume-unchanged <filename> returns fatal: Unable to mark file <filename>.

    What do I need to do to fix this? What is it complaining about and why?

    • Pedro Nascimento
      Pedro Nascimento over 12 years
      Did you figure out? Let me know so I can update the answer with what exactly happened to you.
  • DavidJ
    DavidJ over 10 years
    You'll still get this same error if your files are staged, so you may need to do a git reset HEAD <file> first.