I have come to find that a lot of people are confused about .gitignore. Let’s talk a bit about what the file does, how to interact with it, and how to know if it’s not ignoring files like it should.

What it is

.Gitignore intentionally leaves files untracked in git. This is a very useful and important feature. When you are working in a team setting, you don’t want to overwrite each others files. Those are the files that are specific to your computer, so each one should be unique.

How it looks in git

It should look as if git has no idea your file is there—except for when you actually look in your gitignore file. If anything that is in your gitignore file is ever being tracked by git, you have a problem.

One thing to be aware of

Git will not ignore a file that has already been tracked. In order to ignore a file that has already been tracked, the file must become untracked. To do this you can use git rm –cached filename

It can remember

A great way to save time and energy is to utilize global gitignore. You can set up your computer to always ignore certain files, be it a specific file type or your API keys.

The usual suspects

For example, here is what your .gitignore file might look like when working with WordPress.

.htaccess

wp-content/uploads/

wp-content/blogs.dir/

wp-content/upgrade/

wp-content/backup-db/

wp-content/advanced-cache.php

wp-content/wp-cache-config.php

sitemap.xml

*.log

wp-content/cache/

wp-content/backups/

sitemap.xml.gz

wp-config.php

Resources

Github has a useful resource with popular .gitignore templates. Check it out here.

Paul Weinert
Author

Paul Weinert is our founder, managing principal and spirit animal. He’s one of those odd people you meet that was born in Portland, grew up here and still lives here for some reason. If you had two words to describe Paul after meeting him, we’d bet you’d use “charmingly quirky”.

Paul started GRAYBOX in February 2009, and for the first four years, GRAYBOX had a blend of a contract staffing firm and a traditional agency. GRAYBOX then hired our first employees in 2012 and has been growing ever since. Professionally, Paul has a background in internet business consulting, working especially with mid-market ecommerce, healthcare, and tech companies. He worked as a user experience designer, web developer and internet marketer. Nowadays, Paul serves as our company visionary, team mentor and head of executive leadership — Paul is extremely proud of the entire team and the company. He’s constantly humbled by the team’s awesomeness and the caring community that’s sprung up from his initial ideas.

Beyond GRAYBOX, Paul is married, has two young boys and lives in NE Portland. He’s also an active foster parent, mentors other local entrepreneurs, and volunteers on local non-profit boards. Businesswise, aside from GRAYBOX, Paul has started a few other businesses and is an active investor in the local startup scene.

For the sheer joy of it, let’s play 2 truths and a lie:

  1. Paul firmly believes that any activity would be better if on a boat.
  2. Other than this whole Internet thing, Paul has basically no other skills or expertise in anything.
  3. Paul is rare unicorn, actually born and raised in Portland.