Hello everyone!

We have been investing plenty of personal time and energy for many years to share our knowledge with you all. However, we now need your help to keep this blog running. All you have to do is just click one of the adverts on the site, otherwise it will sadly be taken down due to hosting etc. costs. Thank you.

You have done some changes to a file and it is listed as "tracked" file but you never want to commit it. You simply want to avoid it being indexed with git add command. For this purpose, we use git update-index --assume-unchanged command. For more information, click git update-index link.


Check the current status


inanzzz@inanzzz:~/project$ git status
On branch develop
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)

new file: another_file.html

Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)

modified: index.html.twig

Untracked files:
(use "git add <file>..." to include in what will be committed)

new_file.txt

Update directory cache


We want to update directory cache so that "index.html.twig" is removed from working tree.


inanzzz@inanzzz:~/project$ git update-index --assume-unchanged index.html.twig

Check the current status


As we can see "index.html.twig" is not tracked anymore.


inanzzz@inanzzz:~/project$ git status
On branch develop
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)

new file: another_file.html

Untracked files:
(use "git add <file>..." to include in what will be committed)

new_file.txt

Revert what you have done


You've changed your mind and want to track the file again.


inanzzz@inanzzz:~/project$ git update-index --no-assume-unchanged index.html.twig

Check the current status again


inanzzz@inanzzz:~/project$ git status
On branch develop
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)

new file: another_file.html

Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)

modified: index.html.twig

Untracked files:
(use "git add <file>..." to include in what will be committed)

new_file.txt