Harsha Hegde
Harsha Hegde

Reputation: 1

git- filter certain file

I have a constants file, this file is needed but every developer keeps changing this for his environment and often pushes this changed file. Is there a way that there can be a filter where in this constants file will not get added/pushed. .gitignore does not help as we need that file in the repo with the default configuration for someone who clones the project afresh. I just want to keep it out of the developers commit changes Asking every developer not to add this constant file in this commit and enforcing this is other dirty way

regards, Harsha

Upvotes: 0

Views: 117

Answers (2)

Shimon Rachlenko
Shimon Rachlenko

Reputation: 5517

For the default configuration you may put some file called constants-defaults or so in your repo. After that you can ignore the constants file with .gitignore. Someone that checks out the fresh copy will have to copy the constants-defaults to constants file and to change it.

Upvotes: 1

kaeso
kaeso

Reputation: 341

Assuming that you have full access to the remote repository (ie. you can put hooks there), you can easily do that with a pre-receive hook that check if the pushed commit want to modify the immutable file, and deny it if so.

If you need some hints on how to write such a hook, check this other question on git pre-receive hooks (python-based answer).

Upvotes: 0

Related Questions