Reputation: 325
I have a branch where I have a file called keys.py. The file contains some private keys I do not want to share with other on my repository, but I'd like to leave a file called keys.py inside the repo to be used like a template. I also need to avoid tracking other people's changes to key.py.
I tried to push the template file keys.py and then I created a .gitignore file to ignore keys.py but it seems like it has no effect...
I am missing something but i can not figure out how to solve my problem... any hint?
Upvotes: 1
Views: 711
Reputation: 2551
As far as I know, the common approach for this problem is to have a keys.py.example, and when someone clones the repo, copy it to keys.py and change the values as necessary (you can write it on the README). You can do it with this steps:
git rm keys.py
, so the keys.py that you have on the repo gets removedkeys.py
on your .gitignore filegit add .
to add all this changes on the commitgit commit
to commit the removal of the file from the repo, the example file and the gitignore changesUsually this kind of values goes on a .env file instead of keys.py. I can see you are using python, so you will need to use this package.
Upvotes: 2
Reputation: 325
Many thanks for your replies! I solved the problem in a tricky way:
Upvotes: 0
Reputation: 8345
Yup, .gitignore
has no effect on paths that already have been added to the repository.
For me, the best solution for your problem is to have the real keys.py
outside of the repository, say in a file like $HOME/.appname/keys.py
. The question then is how your application finds this file. A good possibility:
$HOME/.appname/keys.py
as a default.Upvotes: 2