git update-index --assume-unchanged returns error

前端 未结 3 1033
轻奢々
轻奢々 2021-02-19 00:05

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

What do I need to do to fix this? Wha

3条回答
  •  梦毁少年i
    2021-02-19 00:26

    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.

提交回复
热议问题