• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1137
  • Last Modified:

Help with .gitignore please

Git noob looking for clarification of how .gitignore works please.

For instance, I have a CodeIgniter app repo set up on github.com, but I am trying to keep the my account details out of config.php and database.php.

I've been able to get exactly two different scenarios to work:

1. Missing Files

,gitignore working as expected, but the repo does not conatin any config.php or database.php file.

2. Files exist

.gitignore is in place. The config.php and database.php files exist as well and their changes are tracked so sensitive stuff ends up in public.
Is there not a way to upload the original file, push it to the repo, and then add the files to .gitignore so that any further changes are not tracked?
0
TunaMaxx
Asked:
TunaMaxx
  • 2
2 Solutions
 
syahmixpCommented:
You might want to make config.php and database.php without any sensitive information, commit it and push it into server. Then, you can add sensitive information into this file, next commit, you can simply skip committing this two file by untracking it.

See this how to untrack file while keep the file intact: http://source.kohlerville.com/2009/02/untrack-files-in-git/
0
 
TunaMaxxAuthor Commented:
Thanks for the info and the link. There is great info there.

I have since been offered another piece of advice as well. The suggestion was to have:

config.php - with sensitive info in the file
config.example.php - without sensitive info in the file
database.php - with sensitive info in the file
database.example.php - without sensitive info in the file

Then add config.php and database.php to the .gitignore file. The 'example' files will be uploaded, but the other will not. Win win!
0
 
TunaMaxxAuthor Commented:
My solution was accepted in addition to the one by syahmixp as an alternate viable answer.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now