How can I make git ignore future revisions to a file?

I have created a default version of a file included in a git repository. It’s important that when someone clones the repository, they get a copy of this file. However, I would like to set git so that it ignores changes to this file later. .gitignore works only on untracked files.

My motivation is that this file contains machine-specific information. I would like to provide default values, while allowing people to make local changes that won’t get pushed back to the origin repository, creating merge conflicts when we pull new changes.

We are generally pretty lazy and use git add . a lot, so I’m pretty sure if I can’t tell git to ignore this file, changes to it will end up getting committed and pushed.

To summarize,

  1. I would like to create a file, call it default_values.txt that is added to my git repository and is included when someone clones that repository.
  2. git add . should not add default_values.txt to the commit.
  3. This behavior should be passed on to any clones of the repository.

7 Answers
7

Leave a Comment