Tell git to never update the file

I have several files in git (namely, for configuration files) that I need in the git repository, but I don’t want them to ever be updated (for some reason they were launched and made, it changes the configuration file).

So, I can say that git ignore any CHANGES in the file, but save the original file in the repo? Currently, the only way I have discovered to do something like this is to add the file to the .gitignore file, and git to add the file to the project directly (using -f to override). Is there a better way?

+5
source share
2 answers

I would not go around these files with git at all. I would put them in yours .gitignore, so git ignores them and puts the template files (e.g. foo.templatefor a file with a name, fooor maybe template/foo) in git. Then, when you clone the repos, you can copy and modify them, and git will not do anything with the copies, still managing the templates. If you have several of these files, you can provide a script or make a rule or something similar to populate all your configuration files from your templates to simplify setup.

, . , , . , , - , ; , . , , , , . , ; , , , , , .

+4

git update-index --assume-unchanged .

--assume-unchanged ( , .gitignore ). git , . Git(), ; , , , .

+3

All Articles