Working with two different "remotes" with git

0

I would like to know how do I delete the sensitive data (passwords and etc) from the commit of a remote repository, but holding on to another? I explain:

I have a repository in Github and another in Heroku, my project is pointing to the two repositories. When uploading in heroku I need to leave the sensitive data as database password, AWS and etc. In Github this information should not rise, but when I give a "git add." and then a "git commit -m ..." this commit stays on the stage, I can send it to Heroku only by giving a "git push heroku", but when I need to change something in the project and send it to github this time sensitive information will be visible in this penultimate commit, was confused, but it became clear rs?

Note: it is not a matter of not observing the file, but excluding a commit of the stage (which contains the sensitive data), keeping other changes from the last commit.

    
asked by anonymous 14.09.2018 / 01:49

1 answer

1

Git and versioning systems in general should not save sensitive data like passwords and credentials , even in private repositories. This is precisely because once in history this type of problem becomes common.

The solution that Heroku itself recommends is to save this data in environment variables and in your code you just access the data. So they never stay in history and you do not risk accidentally sending them to a public repository.

Documentation and examples here

    
20.09.2018 / 01:59