I'm developing some web application (php, codeigniter). Today a time to push it to github has come, but I've encountered an issue I can't manage.
I've got 2 branches:
By credentials I mean: database login, password, host, user; oauth services id / secrets; encryption_key. Credentials are stored in 2 separated files within /application/config folder.
The idea is that I'll make all changes on dev, than merge dev into master, and pull master content to github (but master can't contain my private credentials).
This is what I've done till now:
And it's pretty cool till now - I've got my project code on github with no credentials within. Next I need to make some changes in my project, so I:
So now I need to make some change in dev, upload it and pull to github so I:
What I expected to happen: Git will ask me which version of configs should be used in 'master' as it is different in both branches. I will use diff to chose a 'master' verion of files (which does not contain credentials). Git will remember my choice, and in the future I will not have to chose again when I'll merge dev into master. Git works like this on one of my other projects, where dev is a master branch and instantions are it's children (In this case dev is a child and I merge child into parent).
What happened: Git just copied credentials from dev to master, did not ask me about that. So now my master branch is 'tainted' by credentials and I can't push it to github anymore.
My questions are:
Please let me know if anything is unclear, any help will be appreciated.
Git will only flag a conflict if files in your master branch were changed after your original branch to dev, then the same files were changed in dev.
I suggest you add a .gitignore entry for your credentials, or separate them using an ENVIRONMENT variable, in codeigniter this is very easy, all you have to do is on your apache config (vhost if your using them) is add SetEnv APPLICATION_ENV development
then you can add a folder inside application/configs
called development
, now when you are running in development environment, these configs will take precedence over the ones in the base config directory.
This isn't so much about gitignoring files, or removing commits, but a good file structure, and environment setup to differentiate between the separate environments, you an use development
, staging
, and production
(which is the default)
otherwise add a .gitignore row to tell git to ignore those certain files.
Git ingore will help. Read this blog post for solution.
http://blog.pagebakers.nl/2009/01/29/git-ignoring-changes-in-tracked-files/
You can include the credentials from a configuration file and add that file to .gitignore
.
The config file can consist of settings for the dev, preproduction and production environments.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.