Allow Local and Production Versions of a File in Git Repository

If you have a file (such as a database.php file) that has different contents locally than what needs to exist in production, follow the steps below. After following these instructions, you will have two different versions of a file; one for local use and one for production.

Step 1: Run git update-index command

git update-index --assume-unchanged config/database.php

Now, any changes that you make to this file will not change the git repo (allowing you to have Local and Production Versions of a File in Git Repository).

What if I want to undo git¬†update-index –assume-unchanged?
If you would like to commit an actual change of that file to the git repo, run the following command (it i the opposite of –assume-unchanged).

git update-index --no-assume-unchanged config/database.php

Leave a Reply

Your email address will not be published. Required fields are marked *