Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
.gitignore file for a general web project - Bare Minimum Git
# -----------------------------------------------------------------
# .gitignore
# Bare Minimum Git
# ver 20220128
# From the root of your project run
# curl -O
# to download this file
# This file is tailored for a general web project, it
# is NOT optimized for a WordPress project. See
# for a WordPress specific .gitignore
# This file specifies intentionally untracked files to ignore
# 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:
# 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 (this is not an ignored file by default)
# 20140407 Initially Published
# -----------------------------------------------------------------
# ignore all files starting with . or ~
# ignore node/grunt dependency directories
# ignore composer vendor directory
# ignore components loaded via Bower
# ignore jekyll build directory
# ignore OS generated files
# ignore Editor files
# ignore log files and databases
# ignore compiled files
# ignore packaged files
# ignore private/secret files
# --------------------------------------------------------
# BEGIN Explictly Allowed Files (i.e. do NOT ignore these)
# --------------------------------------------------------
# track these files, if they exist
Copy link

fredgrott commented Dec 1, 2017

Thanks for posting this as I was looking for exactly this gitignore file....switched from native java android coding to web and design and did not have an adequate gitignore setup for web projects

Copy link

juanma386 commented Jul 6, 2018

WooOoow, very good, thanks.

Copy link

5pid3rm3n commented Oct 7, 2018


Copy link

JohannesBe commented Jul 5, 2019

Please add a section for secrets (e.g. .pem, .key files etc)

Copy link

salcode commented Jul 5, 2019

@JohannesBe thanks for the feedback, this is a good idea

Off the top of my head it seems we should add the following


Copy link

juanpabloisabella commented Jul 22, 2020


Copy link

PotLid commented Jul 27, 2020

Thanks for the sharing!

Copy link

titelplusplus commented Jan 8, 2021

Thanks for the sharing. I will try this file and send you feedback. It looks very good. ;-)

Copy link

YashTotale commented Jan 13, 2021

This is great! I think adding .DS_Store in a misc category would be a good idea 😄

Copy link

salcode commented Jan 14, 2021

Hi @YashTotale,

I believe

# ignore all files starting with . or ~

should ignore .DS_Store. If you are seeing any different behavior let me know.

One note is that if you've added a file (e.g. .DS_Store) to your Git repo before you add this .gitignore, the file will not be ignored because it is already part of the repo.

Copy link

YashTotale commented Jan 14, 2021

Oh, I glossed over that section. Thanks!

Copy link

version0chiro commented Feb 11, 2021

Should we add .env to it too? Like I am new to .gitignore usage so I just had that doubt.

Copy link

salcode commented Feb 11, 2021


Yes, .env should be excluded. See Should I add .env to .gitignore?.

In this case, I'm ignoring all files that start with a period with a few exceptions (you can read more about this technique at .gitignore Hidden Files with Exceptions).

Reviewing this made me realize, I had not added .env.example to my list of allowed files that start with a period (.), so I've updated this .gitignore - thanks.

Copy link

WaleedTariq109 commented Aug 5, 2021

Thank you soo much! This is really helpfull.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment