# Ignoring Local Changes in Git

Sometimes you want to change a file locally—like .vscode/settings.json, a .env file, or other config—but don’t want Git to track those changes. Here's how you can do that.

## Option 1: .git/info/exclude

If the file is not tracked (i.e., not in the Git index), you can add it to .git/info/exclude. This works just like a .gitignore file, but only affects your local clone.

.vscode/settings.json
.env

This is ideal for ignoring files you never want tracked in your local repo, without touching the shared .gitignore.

## Option 2: git update-index --assume-unchanged

If the file is already tracked (committed in the repo), you can't use .gitignore. Instead, run:

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

This tells Git to ignore local changes to that file — it won't show up in git status or get included in commits.

To reverse it:

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

To see which files are being hidden this way:

git ls-files -v | grep '^h'

### Warning

If someone else updates the file in the repo, git pull may fail due to conflicts. In that case:

  1. Run git update-index --no-assume-unchanged
  2. Stash or discard your local changes
  3. Pull changes
  4. Restore your local edits (if needed)