I occasionally run into a situation with Git where I have modified a file but have no intention of committing the change to the repository. This most often happens with computer specific configuration files. My config/database.yml in Rails projects can spend a lot of time in a dirty state if one of my dev machines has a root mysql password and the other does not.
Git will ignore untracked files that are added to .gitignore files or the .git/info/exclude file. For files that git knows about and is already tracking there is a obscure way to tell git to ignore changes to those files.
git update-index --assume-unchanged config/database.yml
When you have made changes to the file that you want to commit you'll need to execute the inverse (--no-assume-unchanged) for git to acknowledge that the file has changed.
References:

Another option is to not store the database.yml file in your git repository at all. Usually what we do is rename any config files to
NAME.yml.example(orNAME.example.yml) and store those, while adding a gitignore for the original file. That way there's no way anyone can change database.yml and break your merge. Plus, it makes it easier to check out a project and get running - just do afind . -name "*.example"or `find . -name ".example." in the root of your rails app to find all the files you'll need to configure.For the password problem in particular, you can use Erb in the database.yml file:
And if you want to ignore an already tracked file, add it to .gitignore, then remove it from Git without deleting it with git rm --cached config/database.yml