Git Ignore Tracked File

Written by
Published
Updated
Typical Read
1 minutes
Find your next web developer job
Drupal Web Developer at On Fire Media (San Antonio, TX)

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.

Did you find Git Ignore Tracked File useful? Get articles in your inbox.

…and don’t worry, I hate spam as much as you. Expect to hear from me at most once a week.

Share on facebook
Share on twitter
Share on linkedin
Share on reddit
Share on facebook

Stay updated.

Get a weekly email with the latest trends in web development & SEO.

Write a guest post.

Have an interesting article or idea? Become a guest blogger & pitch me your concept today.

1 comment on “Git Ignore Tracked File”.

Levi

# Jul 9, 2016

This is incredibly helpful for when "settings.php" finds its way into a Drupal repo. Bookmarked for the next time…

Join the conversation.

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

All comments posted on 'Git Ignore Tracked File' are held for moderation and only published when on topic and not rude. Get a gold star if you actually read & follow these rules.

You may write comments in Markdown. This is the best way to post any code, inline like `<div>this</div>` or multiline blocks within triple backtick fences (```) with double new lines before and after.

Want to tell me something privately, like pointing out a typo or stuff like that? Contact Me.