Noam
Noam

Reputation: 3145

How to ignore an existing file in git repo?

I'm using git as my version control tool. I have a local.properties file in my remote repository. Every team member has to have this file but git should ignore this file only in terms of changes - not existence. I tried adding this file to .gitignore file (the one in the root directory), but it seems like git is ignoring this request... since I (or any other team member) can still commit and push changes on this file.

What am I missing?

Thanks

Upvotes: 1

Views: 1921

Answers (1)

Vampire
Vampire

Reputation: 38639

You are missing that git ignore mechanism only works for untracked files and you can also always force a file to be added with -f even if it is ignored. You cannot ignore changes to an untracked file. You might read about --ignore-untracked, but this should never be used unless you are a Git expert. Rename your checked in file to local.properties.sample and make your developers copy and adapt it to local.properties which then is in .gitignore.

Upvotes: 4

Related Questions