Daniel
Daniel

Reputation: 607

Keeping API Credentials out of GitHub Source Control

I am writing an open source program that relies on the twitter API. When I make a commit I would rather not redact the keys every time. An idea I had was to create a credentials file and add it to the .gitignore file. Is this a viable solution or is there a better way?

Upvotes: 0

Views: 41

Answers (1)

DopplerShift
DopplerShift

Reputation: 5843

Another way would be to commit some version of the credentials file to git. Then add the secret information to the file, but tell git to ignore changes to that file with:

git update-index --assume-unchanged [credentials file]

The downside of this is that in this case, the ignore "command" has to be run on each individual clone of the repo (or at least those where the secrets are entered into the file).

Personally, I usually opt to just add it to .gitignore, but if I have a file where I only want to ignore parts of it, I do as described above.

Upvotes: 1

Related Questions