Keep file in a Git repo, but don't track changes

Question

I need to include some files in my GitHub repo, but not track changes on them. How can I accomplish this? An example use case is for a file that includes sensitive user information, such as login credentials.

For example, I deploy a new installation of this framework to a new client, I want the following files to be downloaded (they have default values CHANGEME) and I just have to make changes specific to this client (database credentials, email address info, custom CSS).

// The production config files. I want the files but they need to be updated to specific client needs
application/config/production/config.php
application/config/production/database.php
application/config/production/tank_auth.php
// Index page, defines the environment (production|development)
/index.php
// All of the css/js cache (keep the folder but not the contents)
/assets/cache/*
// Production user based styling (color, fonts etc) needs to be updated specific to client needs
/assets/frontend/css/user/frontend-user.css

Currently if I run

git clone [email protected]:user123/myRepo.git httpdocs

and then edit the files above, all is great. Until I release a hotfix or patch and run git pull. All of my changes are then overwritten.

Answer

git has a different solution to do this. First change the file you do not want to be tracked and use the following command:

git update-index --assume-unchanged FILE_NAME

and if you want to track the changes again use this command:

git update-index --no-assume-unchanged FILE_NAME

git-update-index documentation

git add only modified changes and ignore untracked files

Add all files to a commit except a single file?