Glad You're Ready. Let's Get Started!

Let us know how we can contact you.

Thank you!

We'll respond shortly.

Ignoring Tracked Files in Git

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.


  1. Stephen says:

    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` (or `NAME.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 a `find . -name “*.example”` or `find . -name “*.example.*” in the root of your rails app to find all the files you’ll need to configure.

  2. Yarrow says:

    For the password problem in particular, you can use Erb in the database.yml file:


  3. Mark Wilden says:

    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

Post a Comment

Your Information (Name required. Email address will not be displayed with comment.)

* Copy This Password *

* Type Or Paste Password Here *

Share This