I feel like this question must have been asked before, but I'm not finding it on here. I have a file that I want in a GitHub repo, in this case a file in which the user would paste their API keys after cloning. I want this blank file to be cloned down, but I don't want it to be tracked or pushed. I already have it listed in the .gitignore file that is contained in the repo, yet after pulling and modifying the file, git status
still shows the file as being tracked and having changes that need to be committed. How can I get around this?
Asked
Active
Viewed 35 times
1

jwong1219
- 11
- 1
-
1rules added to `.gitignore` after the fact (ie after a file has been tracked) do not affect tracked files... as far as i know you would have to add the rule, delete any files affected by the rule that are tracked, commit and push these changes, THEN re add the file ... with that being said i don’t think you can do what you wanna do... typically you have a folder that is tracked but not the contents of the folder ...and in that folder are ignored files that everyone has to add their private files too – mad.meesh Jan 16 '18 at 01:11
-
Possible duplicate of [How do you tell git to permanently ignore changes in a file?](https://stackoverflow.com/questions/2673232/how-do-you-tell-git-to-permanently-ignore-changes-in-a-file) – Taylor Wood Jan 16 '18 at 01:17
-
git may not be the best solution for this. your application bootstrapper should generate it; whether it's with something like Chef, Puppet, or Ansible, or as a manual step. your app should gracefully fail if the file is not present or doesn't have the expected data – Derek Jan 16 '18 at 02:05
1 Answers
0
You could do something like this via Github Enterprise's pre-receive hooks functionality.
From the readme, you can create a pre-receive hook that:
Prevents sensitive data from being added to the repository by blocking keywords, patterns or filetypes.

Adil B
- 14,635
- 11
- 60
- 78