I'm new at git so please bear with me.
Say i have a file under version control that includes sensitive data. Sure enough, I put that file in my .gitignore file, so it doesn't get pushed to the repo. The problem now is somewhere in my project i have a line like
#include <sensitivedata>
or whatever your language of choice is. The problem is whenever somebody clones from that repo, that file is missing and he gets a fatal error when trying to build / compile the solution.
So, instead of pushing the file I'm actually working on I want to push some dummy file with the same name instead, where I place a comment like
// replace the next line with the sensitive data!!!
How would I do this?
i do not know if the c++ preprocessor is able to do this (i assume the code shown above is for some c-style preprocessor), but here is what i do in similar cases:
commit in git:
put in gitignore:
and then i have code that basically does:
that way i can supply some sensible default and have a simple and clean way to override it.
You could use .gitatrributes to filter the contents:
.gitattributes
.git/config
I threw in a 'keepMine' merge to prevent accidental merges. However, AFAIK merge should not even kick in, as local changes would be effectively 'invisible' due to the
clean
filter step. Regardless of what's actually insecrets.h
, the repo file will always contain:E.g.: