1

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).

fxm
  • 123
  • 3
  • 1
    Git ignore does not work that way. Why are people changing this committed files, what are they? Please edit the question to clarify. – AD7six Mar 14 '22 at 10:02
  • 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). – fxm Mar 14 '22 at 10:03
  • 1
    Sounds like you have config/user-specific variables in a script, where it should be separate. Adding that script to the question would be helpful. – AD7six Mar 14 '22 at 10:06
  • Does this answer your question? [Gitignore doesn't work properly (Specifically "Don't commit files that you don't want to track")](https://stackoverflow.com/a/13070714/761202) – AD7six Mar 14 '22 at 10:07
  • "with three parameters in the beginning" - I'm not sure how applicable this is for You, but you could make the script load those parameters from the file that is outside the repository.. or maybe read them from environment variables. – TeWu Mar 14 '22 at 11:42
  • Thanks! I do that in other places, but here it's not very helpful and it is way easier to have them there interactively. – fxm Mar 14 '22 at 13:42

1 Answers1

1

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.

nixlarfs
  • 106
  • 8
  • Thanks! I had thought about the template solution as well, but wanted to check if there was an git-integrated possibility. Now there is a template folder. ;) Thanks! – fxm Mar 14 '22 at 10:34