Pretty General .gitignore File (Using Git 2.5)

Integrated Development Environments (IDEs) and other related development build tools (Gradle, etc.) seem to have the habit of leaving a mess of unnecessary files in your directory structure. I use a number of different IDE’s so I see a lot of these temp files and don’t want them mixed in with my source code.

Fortunately, I use “git” which allows for a “.gitignore” file which allow one to make entries that “pattern out” these unwanted (but necessary for the build) files and in helping to keep your source repository clean.

For a while I was building this file on a per-project basis. But, it occurred to me that I could just start one big generic “.gitignore” file and use across all (most?) of my IDEs and projects. There are a lot of recommendations in this file. Not all will pertain to you but you may find it a helpful start. And, I must admit that it leans toward the fact that I use NetBeans (with Gradle Plugins), IntelliJ and to a much lessor extant Visual Studio. My Gradle projects tend to have a lot of sub-projects (sub-modules) so eliminating unwanted files recursively is important.

Feel free to cut and paste what I have below into your own “.gitignore” file. After adding these entries run the git commands below to clean out some of the noisy files that may be in your repository cache. And, please comment below to add, update and/or make a suggestion. Your input is most welcome!

  1. Make sure you are backed up of course!!!
  2. Update, edit or just use my .gitignore entries below
  3. git commit -a -m “Before Updated/New .gitignore”
  4. git rm -r –cached .
  5. git add .
  6. git commit -a -m “After Updated/New .gitignore”

Currently my “.gitignore” contains:

 ###################################
# Hidden Files/Folders In General #
###################################
.*

##################################
# Uneeded Gradle Generated #
# I don’t use the Gradle Wrapper #
##################################
.gradle
/.gradle/
**/.gradle
**/.gradle/
**/.gradle/**
gradle
gradlew
gradlew.bat
.nb-gradle-properties
**/.gradle
**/gradle
**/gradlew
**/gradlew.bat
**/.nb-gradle-properties

###############################
# Compiled and Output Folders #
###############################
[Bb]uild
/[Bb]uild/
**/[Bb]uild
**/[Bb]uild/
**/[Bb]uild/**
[Tt]arget
/[Tt]arget/
**/[Tt]arget
**/[Tt]arget/
**/[Tt]arget/**
[Oo]ut
/[Oo]ut/
**/[Oo]ut
**/[Oo]ut/
**/[Oo]ut/**
[Gg]en
/[Gg]en/
**/[Gg]en
**/[Gg]en/
**/[Gg]en/**

################
# Libs Folders #
################
[Ll]ibs
/[Ll]ibs/
**/[Ll]ibs
**/[Ll]ibs/
**/[Ll]ibs/**

#########################
# Compiled Source Files #
#########################
**/*.com
**/*.class
**/*.dll
**/*.exe
**/*.o
**/*.so

####################
# VIM Backup Files #
####################
**/*~
**/*.swp
**/*#

##############
# Logs Files #
##############
**/*.log
logfile*
**/logfile*

################################################
# Package Files — Git already has compression #
################################################
**/*.7z
**/*.dmg
**/*.gz
**/*.iso
**/*.jar
**/*.rar
**/*.tar
**/*.zip

###############################
# Misc Operating System Files #
###############################
**/*.DS_Store
**/*.DS_Store?
**/*._*
**/*.Spotlight-V100
**/*.Trashes
**/*ehthumbs.db
**/*Thumbs.db
**/*desktop.ini

###############################
# KDE Dolphin Directory Files #
###############################
.directory
/.directory/
**/.directory
**/.directory/
**/.directory/**

########################################
# IntelliJ Generated Files and Folders #
########################################
.classpath
/.classpath/
**/.classpath
**/.classpath/
**/.classpath/**
.project
/.project/
**/.project
**/.project/
**/.project/**
.settings
/.settings/
**/.settings
**/.settings/
**/.settings/**
.idea
/.idea/
**/.idea
**/.idea/
**/.idea/**
.metadata
/.metadata/
**/.metadata
**/.metadata/
**/.metadata/**
*.iml
**/*.iml
*.ipr
**/*.ipr
*.iws
**/*.iws
atlassian-ide-plugin.xml
**/atlassian-ide-plugin.xml

############################################
# Netbeans IDE Generated Files and Folders #
############################################
.nb-gradle
/.nb-gradle/
**/.nb-gradle
**/.nb-gradle/
**/.nb-gradle/**

###################################
# Visual Studio Files and Folders #
###################################
[Bb]in
[Dd]ebug*/
[Rr]elease*/
*_i.c
*_p.c
*.[Cc]ache
*.[Oo]bj
*.aps
*.bak
*.ilk
*.lib
*.log
*.ncb
*.pch
*.sbr
*.sdf
*.suo
*.tlb
*.tlh
*.user
*.vspscc
*.vssscc
Ankh.NoLoad
ipch/
obj/

####################
# Subversion Files #
####################
.svn
/.svn/
**/.svn
**/.svn/
**/.svn/**

#######################################################
# KEEP Gradle Properties, Build & Settings Files !!!! #
#######################################################
!gradle.build
!**/gradle.build
!gradle.properties
!**/gradle.properties
!settings.gradle
!**/settings.gradle

###############################################
# KEEP Git Ignore (This .gitignore) File !!!! #
###############################################
!.gitignore ###################################
# Hidden Files/Folders In General #
###################################
.*

##################################
# Uneeded Gradle Generated #
# I don’t use the Gradle Wrapper #
##################################
.gradle
/.gradle/
**/.gradle
**/.gradle/
**/.gradle/**
gradle
gradlew
gradlew.bat
.nb-gradle-properties
**/.gradle
**/gradle
**/gradlew
**/gradlew.bat
**/.nb-gradle-properties

###############################
# Compiled and Output Folders #
###############################
[Bb]uild
/[Bb]uild/
**/[Bb]uild
**/[Bb]uild/
**/[Bb]uild/**
[Tt]arget
/[Tt]arget/
**/[Tt]arget
**/[Tt]arget/
**/[Tt]arget/**
[Oo]ut
/[Oo]ut/
**/[Oo]ut
**/[Oo]ut/
**/[Oo]ut/**
[Gg]en
/[Gg]en/
**/[Gg]en
**/[Gg]en/
**/[Gg]en/**

################
# Libs Folders #
################
[Ll]ibs
/[Ll]ibs/
**/[Ll]ibs
**/[Ll]ibs/
**/[Ll]ibs/**

#########################
# Compiled Source Files #
#########################
**/*.com
**/*.class
**/*.dll
**/*.exe
**/*.o
**/*.so

####################
# VIM Backup Files #
####################
**/*~
**/*.swp
**/*#

##############
# Logs Files #
##############
**/*.log
logfile*
**/logfile*

################################################
# Package Files — Git already has compression #
################################################
**/*.7z
**/*.dmg
**/*.gz
**/*.iso
**/*.jar
**/*.rar
**/*.tar
**/*.zip

###############################
# Misc Operating System Files #
###############################
**/*.DS_Store
**/*.DS_Store?
**/*._*
**/*.Spotlight-V100
**/*.Trashes
**/*ehthumbs.db
**/*Thumbs.db
**/*desktop.ini

###############################
# KDE Dolphin Directory Files #
###############################
.directory
/.directory/
**/.directory
**/.directory/
**/.directory/**

########################################
# IntelliJ Generated Files and Folders #
########################################
.classpath
/.classpath/
**/.classpath
**/.classpath/
**/.classpath/**
.project
/.project/
**/.project
**/.project/
**/.project/**
.settings
/.settings/
**/.settings
**/.settings/
**/.settings/**
.idea
/.idea/
**/.idea
**/.idea/
**/.idea/**
.metadata
/.metadata/
**/.metadata
**/.metadata/
**/.metadata/**
*.iml
**/*.iml
*.ipr
**/*.ipr
*.iws
**/*.iws
atlassian-ide-plugin.xml
**/atlassian-ide-plugin.xml

############################################
# Netbeans IDE Generated Files and Folders #
############################################
.nb-gradle
/.nb-gradle/
**/.nb-gradle
**/.nb-gradle/
**/.nb-gradle/**

###################################
# Visual Studio Files and Folders #
###################################
[Bb]in
[Dd]ebug*/
[Rr]elease*/
*_i.c
*_p.c
*.[Cc]ache
*.[Oo]bj
*.aps
*.bak
*.ilk
*.lib
*.log
*.ncb
*.pch
*.sbr
*.sdf
*.suo
*.tlb
*.tlh
*.user
*.vspscc
*.vssscc
Ankh.NoLoad
ipch/
obj/

####################
# Subversion Files #
####################
.svn
/.svn/
**/.svn
**/.svn/
**/.svn/**

#######################################################
# KEEP Gradle Properties, Build & Settings Files !!!! #
#######################################################
!gradle.build
!**/gradle.build
!gradle.properties
!**/gradle.properties
!settings.gradle
!**/settings.gradle

###############################################
# KEEP Git Ignore (This .gitignore) File !!!! #
###############################################
!.gitignore