Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools

How do I ignore a file locally with GIT?

I have two files that I work with locally that I don't want to commit to the tree whatsoever. It's my local database settings and it will mess up the master tree if I push that to the remote repo.

What can I do?

1 Answer

You can add it to your .gitignore file.

In your root folder, create a file named .gitignore (touch .gitignore) and add your paths to it.

Example .gitignore:

/config/app.php
/config/database.php

See: Ignoring Files

When you run git status after this you'll notice they aren't in the list of new files.

If they are already in the repository and you don't want to commit your changes, you can run git update-index --assume-unchanged config/db.php.

This will ignore all your changes to that particular file.

See: GIT: ignoring changes in tracked files

Thank you Liam Linacre. That worked for me. :)

If you mark this as the answer, it will appear marked in the forums and may help other people.