Git: Ignoring files

You can ignore files on a project level or have a global ignore file. Git will recursively ignore the specified file patterns.

1. Create a file in a safe location that wont be deleted easily.

$ vi ~/.gitignore_global

2.  Add the following commonly ignored files and directories.

# Eclipse #
target/
bin/
bin-debug/
.svn/
html-template/

# 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

# OS generated files #
######################
.DS_Store
ehthumbs.db
Thumbs.db

Ignoring a directory in git: directoryName/
Ignore a file in git: *.jar or .DS_Store

3. The last step you need to do is associate this file in the git config.

git config --global core.excludesfile ~/.gitignore_global

This will create an entry in your ~/.gitconfig file.

Reference:
Git Ignore Doco

Advertisements