Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Some common .gitignore configurations
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
############
# it's better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
# Logs and databases #
######################
*.log
*.sql
*.sqlite
# OS generated files #
######################
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
@turtledb

This comment has been minimized.

Copy link

commented Apr 9, 2014

GIT with it

@blue-ice

This comment has been minimized.

Copy link

commented May 1, 2014

Thanks, Octocat!

@shacker

This comment has been minimized.

Copy link

commented May 10, 2014

*.pyc would be a good addition here.

@metatomato

This comment has been minimized.

Copy link

commented May 24, 2014

So convenient! Thanks Octocat!

@schwarzwaldsvd

This comment has been minimized.

Copy link

commented May 26, 2014

Useful stuff, thanks!

@Tatsh

This comment has been minimized.

Copy link

commented May 29, 2014

*.pyo and *.pyc and *~ (backup files generated by text editors)

@shafi-codez

This comment has been minimized.

Copy link

commented Jun 9, 2014

even *.bak & *.swp as well can be added

@infn8

This comment has been minimized.

Copy link

commented Jun 10, 2014

Of course GitHub would give their logo an account. Awesome

@ThomsonTang

This comment has been minimized.

Copy link

commented Jun 20, 2014

It's good, thanks. But how to ignore some directories, such as target, out, production?

@sebastiansulinski

This comment has been minimized.

Copy link

commented Jul 3, 2014

Great resource - many thanks for sharing.

@dreftymac

This comment has been minimized.

Copy link

commented Jul 17, 2014

Some examples with directories per https://gist.github.com/ThomsonTang suggestion would help round out this already excellent tip

@antoniojlm84

This comment has been minimized.

Copy link

commented Aug 6, 2014

Thank you for this great contribution!

@markmatchbyte

This comment has been minimized.

Copy link

commented Aug 13, 2014

Thanks used this a number of times on projects

@VinnyFonseca

This comment has been minimized.

Copy link

commented Aug 13, 2014

I think .dll files are important if you're developing with .NET.

Also, you could include .ai, .eps, and .psd on it.

Thanks, for the great snippet.

@Adrien-Depraute

This comment has been minimized.

Copy link

commented Aug 22, 2014

nice! you should add sass-cache folder too ;)

@ghost

This comment has been minimized.

Copy link

commented Sep 1, 2014

Awesome.

@Sivakumarannareddy

This comment has been minimized.

Copy link

commented Sep 5, 2014

awesome document. thanks.

@zpetr

This comment has been minimized.

Copy link

commented Sep 9, 2014

Hi, I added some IDE files (of NetBeans, Eclipse and Zend Studio) to ignore. Look at:
https://gist.github.com/zpetr/e783d537f8a40bb6ec16

@Kafei59

This comment has been minimized.

Copy link

commented Sep 24, 2014

Surely, *~ and *# for emacs users

@matheusagcosta

This comment has been minimized.

Copy link

commented Sep 28, 2014

Very helpful. Thanks

@jjsub

This comment has been minimized.

Copy link

commented Oct 8, 2014

How I can ignore a specific directory ?

@miguelarauj1o

This comment has been minimized.

Copy link

commented Oct 8, 2014

very helpful :)

@SkullMasher

This comment has been minimized.

Copy link

commented Oct 9, 2014

Thanks Octocat !

@cirosantilli

This comment has been minimized.

Copy link

commented Oct 10, 2014

tags

@muhammad-meraj

This comment has been minimized.

Copy link

commented Oct 14, 2014

Helpful ๐Ÿ‘

@MrMysteri0us

This comment has been minimized.

Copy link

commented Nov 1, 2014

.iml :)

@zagabona

This comment has been minimized.

Copy link

commented Nov 14, 2014

Add these to exclude media extensions:

Images

*.jpg
*.gif
*.png
*.svg
*.ico

Video

*.wmv
*.mpg
*.mpeg
*.mp4
*.mov
*.flv
*.avi
*.ogv
*.ogg
*.webm

Audio

*.wav
*.mp3
*.wma

Fonts

*.eot
*.ttf
*.woff

@zagabona

This comment has been minimized.

Copy link

commented Nov 14, 2014

.idea
(PHPStorm)

@nojacko

This comment has been minimized.

Copy link

commented Nov 28, 2014

This gist is pretty much defunct by https://github.com/github/gitignore

@KaushikRay

This comment has been minimized.

Copy link

commented Dec 19, 2014

.orig files generated by git diff

@AngAven

This comment has been minimized.

Copy link

commented Dec 27, 2014

I love .gitignore thank you

@numediaweb

This comment has been minimized.

Copy link

commented Dec 29, 2014

Some windows files too;

Thumbs.db
desktop.ini
@arulrajnet

This comment has been minimized.

Copy link

commented Dec 31, 2014

To ignore backup files generated by text editor anywhere in the subdirectory

**/*~

To ignore IDE (eclipse / intellij) related files

.classpath
.project
.settings
.idea
.metadata
*.iml
*.ipr
@davidperezgar

This comment has been minimized.

Copy link

commented Jan 12, 2015

And What about Iconr?

@pramitchoudhary

This comment has been minimized.

Copy link

commented Jan 13, 2015

This is very helpful. Thanks guys

@danielcosta

This comment has been minimized.

Copy link

commented Feb 4, 2015

@arulrajnet @cptstarling it is not recommended to ignore entire .idea directory. Instead we should add only the two lines below to local .gitignore file:

/.idea/workspace.xml
/.idea/tasks.xml

This way all good project configuration (for example Code Style, namespaces mapping, etc) will be shared among all team.

@ILM126

This comment has been minimized.

Copy link

commented Feb 15, 2015

Good! Now I can git on with my work ^^

@mindcool

This comment has been minimized.

Copy link

commented Mar 31, 2015

Thanks that really helped

@albacoretuna

This comment has been minimized.

Copy link

commented Apr 30, 2015

What if I want to ignore all .txt files, but one? For example all the txt files out, but keep important.txt ?

@hppavilion1

This comment has been minimized.

Copy link

commented May 1, 2015

*.log isn't working for me. I have the logs 'server.log', 'connected.log', and 'visitorcount.log' in a folder named 'logs', and GitHub Desktop keeps asking me to commit the files whenever they are modified.

I'm using Notepad to add these updates and have rebooted GitHub Desktop. Is there any weird technical feature that I am missing?

@FranckErnewein

This comment has been minimized.

Copy link

commented Jun 1, 2015

for vim users

*.swp
*.swo
@JacobWay

This comment has been minimized.

Copy link

commented Jun 3, 2015

Thanks, add to my file, and add npm install modules directory
/node_modules/*

@milansaha

This comment has been minimized.

Copy link

commented Jun 4, 2015

Thanks man.

@istro

This comment has been minimized.

Copy link

commented Jun 12, 2015

๐Ÿ˜˜ :octocat:

@vpope

This comment has been minimized.

Copy link

commented Jun 18, 2015

๐Ÿ‘

@shady-robot

This comment has been minimized.

Copy link

commented Jun 25, 2015

Wonderful, yo~

@anthonybrown

This comment has been minimized.

Copy link

commented Jun 27, 2015

for vim
*.un~

@ELLIOTTCABLE

This comment has been minimized.

Copy link

commented Jul 17, 2015

Here's a more robust version of the vim ignores for your global .gitignore:

**/*~
**/*.bak
**/*.sw[abcdefghijklmnop]
@DebSreerekha

This comment has been minimized.

Copy link

commented Jul 24, 2015

Thank you . Quite a useful example.

@galeksandrp

This comment has been minimized.

Copy link

commented Aug 10, 2015

It is strange that no one mentioned http://www.gitignore.io - web ui to https://github.com/github/gitignore

@Devnco

This comment has been minimized.

Copy link

commented Sep 13, 2015

Thanks ๐Ÿ‘

@CarsoncodesinTO

This comment has been minimized.

Copy link

commented Sep 14, 2015

@hppavilion1 you should add **/ prefix. It'll include all subfolders as well.

ex:

**/*.log*
@ScottyMJacobson

This comment has been minimized.

Copy link

commented Sep 29, 2015

Should *.sql really be ignored? I've seen instances where raw migrations are saved in .sql format and would be important to commit.

@StenHigh

This comment has been minimized.

Copy link

commented Oct 1, 2015

*.png
*.jpg
*.jpeg
*.gif
*.bmp
*.svg
*.ico
*.psd

@cyrilselasi

This comment has been minimized.

Copy link

commented Oct 6, 2015

does adding .gitignore inside the .gitignore file affect anything generally?

@marnen

This comment has been minimized.

Copy link

commented Oct 27, 2015

\#*\# would also be worth adding.

@giovannipds

This comment has been minimized.

Copy link

commented Nov 19, 2015

And *.sublime-workspace for those who use SublimeText. It's important not adding these files, for security reasons.

@giovannipds

This comment has been minimized.

Copy link

commented Nov 19, 2015

And I agree with @ScottyMJacobson, *.sql files are important for some projects, I'm used to adding the initial version of the database this way. Suits me well... any advices?

@richard-kinder

This comment has been minimized.

Copy link

commented Feb 17, 2016

  • .gitignore to default list.
@Kilobyte22

This comment has been minimized.

Copy link

commented Mar 21, 2016

vim swapfiles (*.swp) should be added as those do not belong into a repository

@towardthesea

This comment has been minimized.

Copy link

commented Mar 25, 2016

thanks so much

@elem83

This comment has been minimized.

Copy link

commented Jun 7, 2016

@jglantonio

This comment has been minimized.

Copy link

commented Jul 4, 2016

thanks , nice work!!

@ealgase

This comment has been minimized.

Copy link

commented Jul 9, 2016

Very useful!

@ghost

This comment has been minimized.

Copy link

commented Jul 27, 2016

Neat! Thanks.

@TWilliamsUK

This comment has been minimized.

Copy link

commented Aug 5, 2016

Huge help, thanks.

@coffeeandwings

This comment has been minimized.

Copy link

commented Aug 6, 2016

Thank you.

@vinyll

This comment has been minimized.

Copy link

commented Sep 21, 2016

# OS generated files #
######################
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

Should be located in ~/.gitignore

@joeblau

This comment has been minimized.

Copy link

commented Oct 12, 2016

Here is a project I'm maintaining for gitignore templates - https://www.gitignore.io

@zillem

This comment has been minimized.

Copy link

commented Nov 22, 2016

I'd add *.msi to my package section.
But thanks Octocat! much easier than finding them myself.

@JulieH2016

This comment has been minimized.

Copy link

commented Dec 13, 2016

Might want to add this specific file example (keys.js) into your .gitignore file if you are using API keys to keep that info private and not copied.

@AnnaKarinaNava

This comment has been minimized.

Copy link

commented Jan 9, 2017

Thanks a lot Octocat!

@WeSpeakEnglish

This comment has been minimized.

Copy link

commented Jan 27, 2017

Thank you for your helpful work!

@marysomerville

This comment has been minimized.

Copy link

commented Feb 16, 2017

Really handy, thanks!

@zearadoua

This comment has been minimized.

Copy link

commented Mar 13, 2017

Thank you for this great contribution! i use it every time ๐Ÿ‘

@allthesignals

This comment has been minimized.

Copy link

commented Apr 12, 2017

  • .env
@Narven

This comment has been minimized.

Copy link

commented Apr 19, 2017

.vscode

@Andreas237

This comment has been minimized.

Copy link

commented May 5, 2017

++++

@determin1st

This comment has been minimized.

Copy link

commented May 10, 2017

where to put this in case of GitHub Desctop App on windows system?

@animeshsrivastava24

This comment has been minimized.

Copy link

commented May 24, 2017

.pyc also

@nakul12345

This comment has been minimized.

Copy link

commented Jun 2, 2017

Very useful and handy. Thanks a lot

@AlexanderYogurt

This comment has been minimized.

Copy link

commented Jul 9, 2017

This is so useful!! Thank you

@nonbinary

This comment has been minimized.

Copy link

commented Aug 3, 2017

A note on .sqlite:
Currently, on a fresh Django installation, the default database name is db.sqlite3, so maybe .sqlite3 should be in here as well?

@vitalkanev

This comment has been minimized.

Copy link

commented Aug 19, 2017

desktop.ini not listed ๐Ÿ˜ฎ

@aldenjenkins

This comment has been minimized.

Copy link

commented Oct 5, 2017

well done

@jackson-sandland

This comment has been minimized.

Copy link

commented Oct 5, 2017

Gittin' jiggy wid it.

@puneet-ibm

This comment has been minimized.

Copy link

commented Nov 6, 2017

We should also add target folder in .gitignore , which is generated by maven as build outcome along with packaged files, as:
target/
*.jar
*.war
*.ear

@umeboshi2

This comment has been minimized.

Copy link

commented Dec 31, 2017

Global git ignores seem to be quite improper when a person is using git-annex. I first experienced this a couple of years ago: umeboshi2/dotfiles@49292a1

Today, while trying to update the git-annex repo for http://ifarchive.org I found a few more. Please add some language that qualifiy the suggestions from github to allow for the addition of certain "ignores" that may need to be tracked above git, yet still be under the constraints of the ignore file.

In all honesty, the suggestions from this gist, with respect to the config being global, and also the use of git-annex, has eliminated many of your suggestions. Even my opinion on *~ wasn't met by http://ifarchive.org. My ignore file is here: https://github.com/umeboshi2/dotfiles/blob/master/gitignore_global

Please understand that I was actually surprised by a "filename~" existing on the mirror and had to really .think about the ignore file. That was not your suggestion, but I was surprised anyway.

My purpose for the comment is to encourage github to provide some sort of "disclaimer" that these files may not need to be ignored.

It's very possible that git-annex may want to "ignore" the global ignores and have it's own global ignore file and not respect the global git ignore config. I will try to bring that point across to Mr. Hess if able.

@elesos

This comment has been minimized.

Copy link

commented Feb 2, 2018

GOOD

@matsonkepson

This comment has been minimized.

Copy link

commented Feb 19, 2018

Please also add *.apk to it, thanks.

@lucanos

This comment has been minimized.

Copy link

commented Feb 25, 2018

Also remember to add

*.

Mac OS seems to have no problems with filenames ending with a period, but Windows does, and GIT on Windows will not interact with a Repo which has any files with this hanging period.

@Joshhortt

This comment has been minimized.

Copy link

commented Mar 9, 2018

Thanks, Bud!

@tradewind2018

This comment has been minimized.

Copy link

commented Mar 19, 2018

thanks!

@TylerJOtte

This comment has been minimized.

Copy link

commented May 21, 2018

Very helpful; thanks!

@d0vi

This comment has been minimized.

Copy link

commented May 24, 2018

Thank you for this, my friend! It will surely complete my .gitignore file โ˜บ๏ธ

@HugoRoca

This comment has been minimized.

Copy link

commented May 29, 2018

Good, thanks ๐Ÿ˜„

@alexmiller64

This comment has been minimized.

Copy link

commented Jun 4, 2018

Thanks Octocat you hero

@jimcullenaus

This comment has been minimized.

Copy link

commented Jun 19, 2018

I agree with @ScottyMJacobson and @giovannipds that *.sql should not be ignored. I've seen them used both for initial database setups and for storing complex queries.

@tinyhazeleyes

This comment has been minimized.

Copy link

commented Jul 7, 2018

Thanks

@alphaCTzo7G

This comment has been minimized.

Copy link

commented Jul 7, 2018

tags should be a good addition here

@patpaev

This comment has been minimized.

Copy link

commented Jul 27, 2018

+1 on removing .sql from this list, Rails can save the schema files as structure.sql which should be checked into version control.

See: https://edgeguides.rubyonrails.org/active_record_migrations.html#types-of-schema-dumps

@nadyro

This comment has been minimized.

Copy link

commented Jul 31, 2018

Thanks ! ๐Ÿ‘

@KeyJoo

This comment has been minimized.

Copy link

commented Aug 14, 2018

Thanks for published

๐ŸŒ„ ๐Ÿ‘

@a-gonzalez

This comment has been minimized.

Copy link

commented Aug 16, 2018

Most excellent. Thank you.

@Anoop-Parackel

This comment has been minimized.

Copy link

commented Aug 31, 2018

Can we ignore web.Config file using gitignore file

@Beyarz

This comment has been minimized.

Copy link

commented Sep 3, 2018

Awesome!

@Shrikant9

This comment has been minimized.

Copy link

commented Sep 11, 2018

Helpful stuff, thanks!

@chrishmorris

This comment has been minimized.

Copy link

commented Sep 12, 2018

In case you have a private key:
*.pem

@Xarick28

This comment has been minimized.

Copy link

commented Sep 12, 2018

Great! Thanks ;)

@acalism

This comment has been minimized.

Copy link

commented Oct 15, 2018

xcuserdata
for Xcode

@jonjack

This comment has been minimized.

Copy link

commented Nov 2, 2018

Nice, geezer.

@jontarg

This comment has been minimized.

Copy link

commented Dec 7, 2018

For sublime users: *.sublime*

@jamesta696

This comment has been minimized.

Copy link

commented Jan 6, 2019

Thanks for this, unfortunately *.exe doesn't exclude exe files.
:(

@19h47

This comment has been minimized.

Copy link

commented Mar 8, 2019

Thanks!

@AJVA2580

This comment has been minimized.

Copy link

commented Apr 16, 2019

How about cloud secrets keys? Is there a way to ignore this .pem etc files.

@zwkcoding

This comment has been minimized.

Copy link

commented May 8, 2019

It is strange that no one mentioned http://www.gitignore.io - web ui to https://github.com/github/gitignore

+1

@kassem241

This comment has been minimized.

Copy link

commented May 22, 2019

thanks

@Areahints

This comment has been minimized.

Copy link

commented May 27, 2019

It is strange that no one mentioned http://www.gitignore.io - web ui to https://github.com/github/gitignore

+1

+100

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You canโ€™t perform that action at this time.