Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8038315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:11:52+00:00 2026-06-05T03:11:52+00:00

I have a config.php which suppose to be different in content in different branches,

  • 0

I have a config.php which suppose to be different in content in different branches, e.g. testing and master.

I have asked in another question (Prevent merging a file from master with Git) that how to prevent this file from merging.

But I am wondering, is this the correct way to do so?

I believe this is quite a common use case to have different config files in different environments and you want the config to keep tracked, right?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T03:11:53+00:00Added an answer on June 5, 2026 at 3:11 am

    The classic way to do this is to have a default config file called config.yml-dist (let’s pretend that your original file is called config.yml) ; you add the original file in .gitignore, and version only the dist one.
    After you deploy your app or re-clone the project, simply cp config.yml-dist config.yml, and change the settings you want.

    This method is used by many people I met in the PHP industry.

    But, there’s one I like much more and that I find cleaner: using environment variables.
    Example:

    username: <%= ENV['MONGOID_USERNAME'] %>
    password: <%= ENV['MONGOID_PASSWORD'] %>
    database: <%= ENV['MONGOID_DATABASE'] %>
    

    This way, you’ll have one single versioned configuration file and won’t have to edit a single one.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using php and mysql. I have a Database config file (db-config.php) which
I have a config.php file for one of my site which holds information needed
I have a php file named config.php in which I defined the application settings
I have a simple PHP app and also a class which contains some config
I have config.php with this... $dbhost = localhost; I want to be able to
in my config.php where i have all constants i set the PATH to a
I have a php file that looks like this: <?php include(config.php); // put the
I have se the below date format in the codeignitor config.php $config['log_date_format'] = 'd/m/Y';
Let's assume we have the following structure: index.php config.inc.php \ lib \ lib \
Hallo I have this script: <? require(lib2/config.inc.php); require(lib2/tpl.class.php); require(lib2/db.class.php); require(lib2/um.class.php); $tpl = new template(templates,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.