Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

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

like image 233
Victorino Machava Avatar asked Sep 19 '16 20:09

Victorino Machava


1 Answers

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"
like image 114
Jeff Puckett Avatar answered Sep 25 '22 15:09

Jeff Puckett