Git Ignore Tracked File

This is a cool feature. You can mark files as “yes, I know this is tracked by Git, but I don’t want my changes committed.”

For example, there’s a config file that’s checked in. You need to make local edits to test with. However, you often accidentally commit those changes (you forget). But you could tell Git to ignore changes in this file. Let’s say we have a file config.php that we want to edit locally and leave edited.

git update-index --skip-worktree config.php

After this, we can commit all we want, and Git will ignore config.xml. If you need to commit a change to it, you can undo this with

git update-index --no-skip-worktree config.php

If you’ve forgotten which files you’ve skipped, you can do git ls-files -v to see.

This is an edge case, but useful for some work flows.

Author: Ben Marshall

Red Bull Addict, Self-Proclaimed Grill Master, Entrepreneur, Workaholic, Front End Engineer, SEO/SM Strategist, Web Developer, Blogger

1 thought on “Git Ignore Tracked File”

Leave a Reply

Your email address will not be published. Required fields are marked *