'git update-index --assume-unchanged not working for me

I am in a project building a web app. We use Git for version control and Gulp for task automation. I would like to temporarily ignore files to a certain folder, the build folder. We tend to commit changes to that folder at the end of the day (or at the end of a coding session).

After some research I found the following command to start ignoring changes to a file:
$ git update-index --assume-unchanged path/to/file

When I run that code to ignore the build folder I see on the terminal: Ignoring path build/

But it still shows changes not staged for that folder so that I have to run git checkout -- build/ before each commit.

What am I doing wrong?

I am using git 2.9.3 on a PC with elementary OS (Ubuntu-based distro).

git


Solution 1:[1]

You're not supposed to change the file with that bit.

When the "assume unchanged" bit is on, the user promises not to change the file and allows Git to assume that the working tree file matches what is recorded in the index.

It's intended to save time on big projects.

This is sometimes helpful when working with a big project on a filesystem that has very slow lstat(2) system call (e.g. cifs).

I think you're looking for --[no-]skip-worktree

When one of these flags is specified, the object name recorded for the paths are not updated. Instead, these options set and unset the "skip-worktree" bit for the paths.

Usage:

git update-index --skip-worktree <file>

Start tracking again:

git update-index --no-skip-worktree <file>

You might forget what you have skipped, so I have an alias created:

[alias]
    skipped = !git ls-files -v | grep --color "^S"

Solution 2:[2]

We can use

git update-index --assume-unchanged path/to/file

to start ignoring changes to a file and

git update-index --no-assume-unchanged path/to/file

to track file again

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jeff Puckett
Solution 2 anubhav solanki