How can I add a secret file to Heroku that I don't want on the GitHub source (Python)

Viewed 1370

I'm trying to add a few files (credentials and API keys) to my Heroku app without having to commit them to a public GitHub repository. How would I go about doing that?

2 Answers

If I recall correctly, you have to push to Heroku and Git separately. If that is the case, then simply commit all your files, push to Heroku. Then reset your files

git reset --soft HEAD~1

Add only the files you want. Commit those files and then push to your remote git repo.

I’d strongly recommend not to complicate your deployment strategy by having different files in your deployment than your version control. You run the risk of missing steps when deploying and breaking your release. Instead, the recommended approach is to use Heroku Config Vars to store secrets such as credentials and keys, as these will persist across releases, see https://devcenter.heroku.com/articles/config-vars for details.

Related