Git skip-worktree and how I used to hate config files

I’m working on a large-ish PHP project right now and there’s always a handful of config files that I need set up differently on my local vagrant box than on production.

Say hello to:

git update-index <file_name>

When update-index is told about a file, it clears any unmerged or needs updating state. It won’t show up on your git status anymore. Handy dandy. To make the incognito status more permanent, just add the skip-worktree flag:

git update-index --skip-worktree <file_name>

When a file is marked as skip-worktree, git will read it as if it were up to date. Any changes made to the file will not be read. The file will be updated on a pull if the upstream file was changed. Git will output a conflict if both the local and upstream file are changed.

Removing the update-index flag:

git update-index --no-skip-worktree <file_name>

List all flagged files:

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