DEV Community

Himanshu
Himanshu

Posted on • Originally published at himanshusb.in

🌲 Git better at ignore-ing

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.

Using update index

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

Redis image

62% faster than every other vector database

Tired of slow, inaccurate vector search?
Redis delivers top recall and low latency, outperforming leading vector databases in recent benchmarks. With built-in ANN and easy scaling, it’s a fast, reliable choice for real-time AI apps.

Get started

Top comments (0)

Redis image

62% faster than every other vector database

Tired of slow, inaccurate vector search?
Redis delivers top recall and low latency, outperforming leading vector databases in recent benchmarks. With built-in ANN and easy scaling, it’s a fast, reliable choice for real-time AI apps.

Get started

šŸ‘‹ Kindness is contagious

Explore this insightful write-up embraced by the inclusive DEV Community. Tech enthusiasts of all skill levels can contribute insights and expand our shared knowledge.

Spreading a simple "thank you" uplifts creators—let them know your thoughts in the discussion below!

At DEV, collaborative learning fuels growth and forges stronger connections. If this piece resonated with you, a brief note of thanks goes a long way.

Okay