Search code examples
gitgitignore

Can I have a file in a git repo, everybody gets it, but it is ignored for everyone?


I have two files I would like in the repository (they are included in clone and update), so everybody has access to these scripts. But I want that changes in them are not tracked and they are never automatically committed (by anyone).

If I put them in the gitignore file and remove them from the repository (and keep a local copy with --cached), then they are not accessible to others anymore.

Am I overlooking a simple way to use the gitignore function to achieve this?

edit: These files are plotting scripts with three parameters in the beginning (which are edited and run locally). Most of the time nothing else in the script changes (and if it did it would be worthy of a commit).


Solution

  • The only way to distribute files via Git is to add them to the repository, and thus changes to the files will be tracked. And if you delete the files and commit the deletion, the deletion will be tracked by Git and distributed to everyone who pulls from you.

    My goto solution is to track a template file, copy this file to an ignored path, edit as needed, and load from this ignored path.