Chris Mendez in For Developers, Tools for Software Engineers, Git

How to tell git to ignore a specific file

I'm currently building a boilerplate Rails 5 project that will allow me to fork and build mid-sized apps quickly and consistently. I'm currently using dotenv-rails with a generic .env file. The catch is that every time I modify .env for my local project, I do not want to accidentally submit it back to Github. The answer was to tell git to assume the file has not been changed.

The hardest part of this process was figuring out how to ask this question in Google. The best explanation was from this Stack Overflow answer

"Ignore changed files to being listed as modified".

git update-index --assume-unchanged .env  

To revert that ignorance, use:

git update-index --no-assume-unchanged .env