• 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 / Starter .gitignore file

Starter .gitignore file

Last updated on January 28, 2022 by Sal Ferrarello

This is my general starter .gitignore file I use for projects. I have a separate .gitignore for WordPress websites.

# -----------------------------------------------------------------
# .gitignore
# Bare Minimum Git
# https://salferrarello.com/starter-gitignore-file/
# ver 20221125
#
# From the root of your project run
# curl -O https://gist.githubusercontent.com/salcode/10017553/raw/.gitignore
# to download this file
#
# This file is tailored for a general web project, it
# is NOT optimized for a WordPress project. See
# https://gist.github.com/salcode/b515f520d3f8207ecd04
# for a WordPress specific .gitignore
#
# This file specifies intentionally untracked files to ignore
# http://git-scm.com/docs/gitignore
#
# NOTES:
# The purpose of gitignore files is to ensure that certain files not
# tracked by Git remain untracked.
#
# To ignore uncommitted changes in a file that is already tracked,
# use `git update-index --assume-unchanged`.
#
# To stop tracking a file that is currently tracked,
# use `git rm --cached`
#
# Change Log:
# 20221125 ignore /dist directory
# unignore /.git-blame-ignore-revs
# 20220720 ignore /build directory
# 20220128 unignore .nvmrc
# 20210211 unignore .env.example
# 20190705 ignore private/secret files
# 20181206 remove trailing whitespaces
# 20180714 unignore .phpcs.xml.dist
# 20170502 unignore composer.lock
# 20170502 ignore components loaded via Bower
# 20150326 ignore jekyll build directory `/_site`
# 20150324 Reorganized file to list ignores first and whitelisted last,
# change WordPress .gitignore link to preferred gist,
# add curl line for quick installation
# ignore composer files (vendor directory and lock file)
# 20140606 Add .editorconfig as a tracked file
# 20140418 remove explicit inclusion
# of readme.md (this is not an ignored file by default)
# 20140407 Initially Published
#
# -----------------------------------------------------------------
# ignore all files starting with . or ~
.*
~*
# ignore node/grunt dependency directories
node_modules/
# Ignore build directories.
/build
/dist
# ignore composer vendor directory
/vendor
# ignore components loaded via Bower
/bower_components
# ignore jekyll build directory
/_site
# ignore OS generated files
ehthumbs.db
Thumbs.db
# ignore Editor files
*.sublime-project
*.sublime-workspace
*.komodoproject
# ignore log files and databases
*.log
*.sql
*.sqlite
# ignore compiled files
*.com
*.class
*.dll
*.exe
*.o
*.so
# ignore packaged files
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
# ignore private/secret files
*.der
*.key
*.pem
# --------------------------------------------------------
# BEGIN Explictly Allowed Files (i.e. do NOT ignore these)
# --------------------------------------------------------
# track these files, if they exist
!.editorconfig
!.env.example
!.git-blame-ignore-revs
!.gitignore
!.nvmrc
!.phpcs.xml.dist
view raw .gitignore hosted with ❤ by GitHub
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

Comments

  1. Chrispian Burks says

    February 23, 2021 at 2:44 pm

    I’m loving all the stuff you’ve been sharing on git! Very helpful and very easy to understand. Especially the way you showed the commits with blocks. Just wanted to say thanks for continuing to teach and help me level up!

    Also, for the default .gitignore file I usually ignore my .idea folder as well. It’s what phpstorm and their suite of editors use for local config much like the sublime ones you have. Just a heads up in case you want to add that to your default template.

    Reply
    • Sal Ferrarello says

      February 24, 2021 at 1:32 pm

      Thanks for the kind words Chrispian, I’m glad my posts are helpful.

      I think since the .idea folder starts with a period (.), it should be ignored. I like to ignore everything that starts with a period and add exceptions, like .gitignore. You can read more about it in .gitignore Hidden Files with Exceptions.

      If you are seeing different behavior, please let me know and I can look into more closely.

      Reply

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