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 8518681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:03:00+00:00 2026-06-11T06:03:00+00:00

I have a PHP config file i’d like to manipulate locally but ignore those

  • 0

I have a PHP config file i’d like to manipulate locally but ignore those changes during git commits to my master repository. I had a .gitignore file which used to ignore this PHP file but bad things happen and now the config.php file is no longer being ignored and I can’t remember how to re-ignore it.

I know people on SO say to use git rm --cached <filename> but I can’t for the life of me figure out how not to make git rm... keep deleting my config.php file.

I’m wondering if someone can list how to ignore my config.php such that I can keep editing it locally but these changes don’t get added to the repo.

here’s the entire contents of my .gitignore:

application/config.php

here’s some php code in my config.php I’d like to keep local and NOT go in my master repo:

$config['base_url'] = "http://localhost/";
//$config['base_url'] = "http://mysite.com/"; // this is the code and NOT
// "http://localhost" that i'd like to keep in my repo

This is what deletes my file:

  1. git rm --cached application/config.php
  2. make changes to the application/config.php file and another file (as a control)
  3. git commit -m 'config.php shouldn't be changed'

    result: 2 files changed, 1 insertions(+), 370 deletions(-) (config.php is 370 lines long)

  • 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-11T06:03:02+00:00Added an answer on June 11, 2026 at 6:03 am

    I solved my own problem. I actually need this:

    git update-index --assume-unchanged <filename>

    Assuming the .gitignore and config.php files being specified as above in my question,
    here’s the complete workflow:

    1. git update-index --assume-unchanged application/config.php
    2. git add -A
    3. git commit -m 'now config.php will be ignored'
    4. git push origin master

    Now http://localhost will remain in the config.php on my local copy of the repo and http://my-site.com will be preserved in the config.php in my master repo.

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

Sidebar

Related Questions

I have a config.php file that creates an array, something like $config = array(
I have a php file that looks like this: <?php include(config.php); // put the
I have a file system structure with symlinks, something like this: folder123 index.php config.php
If I have a config.php file with variables in it like so... config.php :
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 Yii project with a main.php config file and dev.php config file
I have few repositories and each have config.php file that contain information about database
Suppose i have a php file named main.php It Contains following code include 'config.php';
Hello guys I have this code in main.php config file: 'components' => array( '[.........]',

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.