dabljues
dabljues

Reputation: 1947

Git ignore already pushed file

I have a following problem: Basically, I have a Python project which uses a config file, so like config.cfg is present in the root of a project. I've already added, commited and pushed it to repo. And it is empty.

Users can read README to learn how to write one on their own, but I wanted to provide them with an empty one, so they don't have to create it, wonder about paths etc.

The problem is, when I write code/debug, I have this file filled with my own configuration data. And every time when I want to commit, I need to be careful, I cannot git add ., because it will add this modified config.cfg. I've added config.cfg to .gitignore of course, but it doesn't seem to help.

Is it possible to .gitignore already tracked, commited and pushed file, or do I have to always like manually not stage it?

Upvotes: 0

Views: 69

Answers (1)

Philippe
Philippe

Reputation: 31137

You want git update-index --skip-worktree.

A lot of people say to use --assume-unchanged which has a very similar behavior but should be reserved for performance problems on big files.

skip-worktree is intended for files changed by the developer.

So, do:

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

See https://stackoverflow.com/a/13631525/717372 for more details

Upvotes: 2

Related Questions