gitignore for Maven

An example gitignore for Java Maven projects

The .gitignore file is a hidden file in a Git repository that tells Git which files should NOT be committed to the repository.

Examples of files that should NOT be committed:

Each language has its own set of file patterns, e.g.

Some tools, too, have their own set of files that should be in the .gitignore. Github has .gitignore files predefined for frameworks such as Rails and Jekyll (which are both written in the programming language Ruby), the Unity game engine (folks typically write C++ code for this), as well as the Maven version control system.

You can find examples of the files that should be in the .gitignore for various systems by doing a web search on “.gitignore name-of-system-or-tool”.

The repo https://github.com/github/gitignore also has a nice collection of these.

A few useful ones for this course:

A candidate .gitignore for CS56 Maven Projects

# Emacs/vim

*~
*.swp

# VSCode

.vscode
.classpath
.project
.settings/


# MacOS

.DS_Store

# CS56 specific: Secrets files

localhost.json
heroku.json

# Maven (from: https://github.com/github/gitignore/blob/master/Maven.gitignore)

target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
# https://github.com/takari/maven-wrapper#usage-without-binary-jar
.mvn/wrapper/maven-wrapper.jar

# Java (from: https://github.com/github/gitignore/blob/master/Java.gitignore)

# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*