J. Robinson
J. Robinson

Reputation: 929

Git Ignore File - Push with Blank File Not No File

So here is my .gitignore file

.DS_Store
core/prodConfig.php
core/vendor/

The core/prodConfig.php file I would like to still push with the commit, however I'd like to push a blank, empty file but yet still keep the file "not empty" on my machine and retain all the information saved. Is that at all possible?

I want the end user to still be able to see the file in the repo, but not see whats in it.

I've looked online, and used the search function on here and there isn't really that much information on the subject. Maybe because there is a better way to do it?

Upvotes: 1

Views: 209

Answers (1)

Alberto Trindade Tavares
Alberto Trindade Tavares

Reputation: 10366

You can push an empty file, and then execute this command:

git update-index --assume-unchanged core/prodConfig.php

So, from now on, Git will not track the changes on this file, so you can change it locally and those changes will not be committed and pushed.

Upvotes: 1

Related Questions