Jasondecode Jasondecode - 3 years ago 190
Git Question

Github - Syncing website files between local and live servers WITH sensitive data

I just created a project and it is currently on Bitbucket.
Now i want to put it on Github and make it opensource. Im very new to git and i'm kinda scared if i gonna mess it up. I know the basic of clone, commit and push.

I would like to work local and if i made changes i will log in on my live server and pull the new changes. I found a post how to do it but i have one problem. My project contains some sensitive data like API keys and passwords. How can i avoid this? I don't like to change my local sensitive data to push my new changes and then change it back there must be an easier way. Can someone explain me how to do it? thank you!

Answer Source

As long as the sensitive information is separated into one or more individual files, you can use the .gitignore file to tell git to not push the file up to the central repo on Github. Then have a second copy of those files with the correct live values (or defaults, or empty, as needed) on the live server.

Basically, .gitignore tells git to never move those files during push/pull, so you'll have to modify/move/update them manually, but that is the goal here - if I understand the use case right. The files will never be on the central repo, just on the local repos.


  1. Using Git / Ignoring Files at Github
  2. gitignore at git-scm.com
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download