0

I'm writing a web application in PHP and want to opensource it. Right now I have a private git repository, which I don't want to make public (with custom configurations, f.e. db login credentials).

What would be a clean way to opensource the web app? Have a special branch with dummy config files (then my config files would be available too?)? Or fork from the opensourced repository?

I want to track both (the opensourced and the configured repo) with git.

Best,JotPe

1
  • Hi there! Your question is off-topic for Stack Overflow since it is not a direct, programming related issue, but rather about licensing. You may be able to get an answer at Open Source. Be sure to read their on-topic page too. :D Commented Feb 22, 2016 at 1:32

1 Answer 1

1

Right now I have a private git repository, which I don't want to make public (with custom configurations, f.e. db login credentials).

In general, configuration doesn't belong in your repository.

One common approach is to include a configuration "template" like config.ini.template that is tracked, but require users to copy that to config.ini, which is .gitignored, and load configuration from there.

Another approach popularized by Heroku is to load your configuration from environment variables.

If you choose to go down either of these paths, you should know that simply removing your currently tracked files with git rm --cached will not purge them from your repository. Previous commits will still contain your database credentials.

You could use something like BFG or git filter-branch to purge them from your repository, but this will cause commits to be rewritten which can cause serious problems, especially on shared repositories. I don't recommend this option unless you fully understand and accept the implications.

My preferred approach would be to git rm --cached the files (or possibly git mv config.ini config.ini.template), add them to your .gitignore, and then change the credentials themselves.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for your answer! As mentioned on the 12-factor App Website it's a bad idea to include config into code, especially with several branches (develop, production, ...). Assuming I remove the configuration completely from my code, how could I keep track of the config (for my different environments (dev, prod, ...))?
@JotPe, it depends what you mean by "keep track of". Do you need it to be versioned? Your needs may be different from mine, but I rarely need to do that. Do you simply need to document them somewhere? Your repository host might have a wiki that you could use for that. Or you could use a shared Google doc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.