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
.gitignore
instead.
Top comments (0)