Git Hack: Temporarily Ignore File Tracking

UmairQA
2 min readSep 12, 2024

When working on a Git project, you may encounter situations where you need to ignore changes to certain tracked files temporarily. This can be particularly useful when you are making local tweaks to configuration files or making small changes that you do not want to accidentally commit.

Temporarily Ignore Changes with --assume-unchanged

Git provides the option to “assume unchanged” for specific files using the git update-index command. This tells Git to stop tracking changes for a file temporarily, though the file remains tracked in the repository. This can be handy if you're working on a file that you don’t want to commit but don’t want to create unnecessary branches or commits for it.

The syntax for temporarily ignoring changes to a file is as follows:

git update-index --assume-unchanged <file-path>

For example, to temporarily ignore changes to a file named config/settings.json, you would run:

git update-index --assume-unchanged config/settings.json

Once this command is executed, Git will no longer track any changes made to this file locally.

Undoing the Temporary Ignore with --no-assume-unchanged

--

--

UmairQA
UmairQA

Written by UmairQA

Experienced SDET skilled in JavaScript, Python, Cypress, Playwright, CI/CD, Jenkins, Git, Selenium, API testing, Postgres, and MySQL, for robust QA automation.