• Skip to primary navigation
  • Skip to main content
Sal Ferrarello
  • About Sal Ferrarello
  • Speaking
  • Connect
    Mastodon GitHub Twitter (inactive)
You are here: Home / Dev Tips / .gitignore Hidden Files with Exceptions

.gitignore Hidden Files with Exceptions

Last updated on February 13, 2021 by Sal Ferrarello

In most operating systems by default, files that start with a period (.) are hidden. When setting up my .gitignore file, I like to ignore all these hidden files (with a few exceptions).

gitignore All Hidden Files

By adding the following line to my .gitignore file, all files that start with a period (.) will be ignored.

.*

Add Exceptions

There are some files that start with a period (.) that I do want to include in my Git repository (e.g. .gitignore).

I can add these exceptions using an exclamation point (!) in .gitignore (in many languages the exclamation point is the NOT operator).

!.gitignore

Starter .gitignore files

  • General starter .gitignore
  • WordPress website .gitignore
Sal Ferrarello
Sal Ferrarello (@salcode)
Sal is a PHP developer with a focus on the WordPress platform. He is a conference speaker with a background including Piano Player, Radio DJ, Magician/Juggler, Beach Photographer, and High School Math Teacher. Sal can be found professionally at WebDevStudios, where he works as a senior backend engineer.

Share this post:

Share on TwitterShare on FacebookShare on LinkedInShare on EmailShare on Reddit
Warning! This is a draft, not a finalized post. See full draft disclosure.

Filed Under: Dev Tips, Draft, Recommendations Tagged With: Git, gitignore

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Copyright © 2023 · Bootstrap4 Genesis on Genesis Framework · WordPress · Log in