Letâs consider a relatable (albeit slightly exaggerated) scenario.
Itâs been a long, chaotic dayâpacked with code reviews, endless brainstorming sessions, and a CI pipeline that seems determined to sabotage your simple one-line bug fix for an entire week. If only this were fiction.
Amidst the madness, you finally get a notificationâsomeone reviewed your PR. But to your dismay, itâs just one comment. And not even a meaningful one. Itâs about a rogue change in a shared config fileâenv, config.js, playwright.config.js, or the dreaded package.jsonâone of those files that sneaked into your commit unnoticed.
đĽÂ Enters update-index
The git update-index command updates the index - staging area - entries for one or more files. In simpler terms, it helps you git ignore files valid only to your local index - unlike .gitignore, which ignores files for every user commiting to that repo.
đ§ What this does:
- đ Git stops tracking changes to
package.json(locally). - âł You can still pull updates from the repo without needing to stash your changes.
- đ Your local changes wonât show up in
git status, and you wonât accidentally commit them. - đ Persists across branch changes on your local.
Thereâs an alternative flag called --assume-unchanged which achieves a similar function, they defer slightly in how they work in git internals.
While in 90% of your use cases, youâll make do with skip-worktree, hereâs a general brief of they differ:
| Flag | Purpose |
|---|---|
--assume-unchanged |
Hint to Git: "I wonât change this file" |
--skip-worktree |
Directive to Git: "Ignore my local edits" |
đ Note. If the file shouldnât be tracked at all (for everyone), use
.gitignoreinstead.

Top comments (0)