Create a gist now

Instantly share code, notes, and snippets.

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
turtledb commented Apr 9, 2014

GIT with it

@blue-ice
blue-ice commented May 1, 2014

Thanks, Octocat!

@shacker
shacker commented May 10, 2014

*.pyc would be a good addition here.

@metatomato

So convenient! Thanks Octocat!

@schwarzwaldsvd

Useful stuff, thanks!

@Tatsh
Tatsh commented May 29, 2014

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

@shafi-codez

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

@infn8
infn8 commented Jun 10, 2014

Of course GitHub would give their logo an account. Awesome

@ThomsonTang

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

@sebastiansulinski

Great resource - many thanks for sharing.

@dreftymac

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

@antoniojlm84

Thank you for this great contribution!

@markmatchbyte

Thanks used this a number of times on projects

@VinnyFonseca

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

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

@opexsw
opexsw commented Sep 1, 2014

Awesome.

@Sivakumarannareddy

awesome document. thanks.

@zpetr
zpetr 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
Kafei59 commented Sep 24, 2014

Surely, *~ and *# for emacs users

@matheusagcosta

Very helpful. Thanks

@jjsub
jjsub commented Oct 8, 2014

How I can ignore a specific directory ?

@miguelarauj1o

very helpful :)

@SkullMasher

Thanks Octocat !

@cirosantilli

tags

@muhammad-meraj

Helpful πŸ‘

@MrMysteri0us

.iml :)

@cptstarling

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

@cptstarling

.idea
(PHPStorm)

@nojacko
nojacko commented Nov 28, 2014

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

@KaushikRay

.orig files generated by git diff

@AngAven
AngAven commented Dec 27, 2014

I love .gitignore thank you

@numediaweb

Some windows files too;

Thumbs.db
desktop.ini
@arulrajnet

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

And What about Iconr?

@pramitchoudhary

This is very helpful. Thanks guys

@danielcosta

@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
ILM126 commented Feb 15, 2015

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

@mindcool

Thanks that really helped

@omidfi
omidfi 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

*.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

for vim users

*.swp
*.swo
@JacobWay
JacobWay commented Jun 3, 2015

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

@milansaha

Thanks man.

@istro
istro commented Jun 12, 2015

😘 :octocat:

@vpope
vpope commented Jun 18, 2015

πŸ‘

@Root-shady

Wonderful, yo~

@anthonybrown

for vim
*.un~

@ELLIOTTCABLE

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

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

Thank you . Quite a useful example.

@galeksandrp

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

@Devnco
Devnco commented Sep 13, 2015

Thanks πŸ‘

@keyboardflexing

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

ex:

**/*.log*
@ScottyMJacobson

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

@StenHigh
StenHigh commented Oct 1, 2015

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

@cyrilselasi

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

@marnen
marnen commented Oct 27, 2015

\#*\# would also be worth adding.

@giovannipds

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

@giovannipds

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
  • .gitignore to default list.
@Kilobyte22

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

@towardthesea

thanks so much

@jglantonio

thanks , nice work!!

@ealgase
ealgase commented Jul 9, 2016

Very useful!

@ghost
ghost commented Jul 27, 2016

Neat! Thanks.

@TWilliamsUK

Huge help, thanks.

@coffeeandwings

Thank you.

@vinyll
vinyll commented Sep 21, 2016
# OS generated files #
######################
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

Should be located in ~/.gitignore

@joeblau
joeblau commented Oct 12, 2016

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

@zillem
zillem commented Nov 22, 2016

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

@JulieH2016
JulieH2016 commented Dec 13, 2016 edited

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

Thanks a lot Octocat!

@WeSpeakEnglish
WeSpeakEnglish commented Jan 27, 2017 edited

Thank you for your helpful work!

@marysomerville

Really handy, thanks!

@zearadoua

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

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