If you want Git to ignore changes to a file that’s already committed (tracked), use git update-index --skip-worktree. .gitignore and .git/info/exclude only work for untracked files.
.git/info/exclude can’t ignore changes to tracked filesWhen you want to ignore files only in your local environment on a per-project basis, you might think .git/info/exclude is the right tool. But there’s a catch.
Both .git/info/exclude and .gitignore are meant to ignore untracked files. They have no effect on files that are already committed (tracked).
So if you customize a configuration file that’s already in the repository and want Git to ignore your local changes, these won’t help.
--skip-worktreeTo ignore local changes to a file that’s already tracked, use git update-index --skip-worktree:
# Ignore local changes
git update-index --skip-worktree path/to/file
# Revert it
git update-index --no-skip-worktree path/to/file
--skip-worktree isThis tells Git: “I’ll modify this file locally, but don’t track those changes.” It’s useful when you intentionally want Git to ignore modifications, such as local customization of config files.
config/local.py, .env.local, etc.)# List files with --skip-worktree enabled
git ls-files -v | grep '^S'
# If you only want the path names
git ls-files -v | grep '^S' | cut -c 3-
git ls-files -v outputS = skip-worktree is setH = normal tracked fileh = assume-unchanged is setgit config --global alias.skipped "ls-files -v | grep '^S'"
# Usage
git skipped
--skip-worktree vs --assume-unchangedGit also has a similar option, --assume-unchanged, but it’s meant for a different purpose:
| Option | Purpose | Stability |
|---|---|---|
--skip-worktree |
Intentionally ignore changes | Stable (persists unless you explicitly unset it) |
--assume-unchanged |
Performance optimization | Unstable (can be reset by Git operations) |
Recommendation: If you intentionally want to ignore local changes, --skip-worktree is the more reliable choice.
If the same file is updated remotely and you try to git pull, you may get conflicts. In that case:
# Temporarily disable skip-worktree
git update-index --no-skip-worktree path/to/file
# Stash your local changes
git stash
# Pull from remote
git pull
# Restore your changes if needed
git stash pop
# Enable skip-worktree again
git update-index --skip-worktree path/to/file
Since --skip-worktree is a local setting, you should use .gitignore for files the whole team should ignore.
.gitignore or .git/info/excludegit update-index --skip-worktreegit ls-files -v | grep '^S'It’s a subtle but useful technique that lets you develop without worrying about local, environment-specific config tweaks.