Back-End
Java 및 Eclipse gitignore 적용방법
외계공룡
2022. 10. 3. 16:24
아래 코드를 복사해서 .gitignore 파일에 붙여넣어서 사용하시면 됩니다.
# Created by https://www.toptal.com/developers/gitignore/api/java,eclipse
# Edit at https://www.toptal.com/developers/gitignore?templates=java,eclipse
### Eclipse ###
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
.recommenders
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# PyDev specific (Python IDE for Eclipse)
*.pydevproject
# CDT-specific (C/C++ Development Tooling)
.cproject
# CDT- autotools
.autotools
# Java annotation processor (APT)
.factorypath
# PDT-specific (PHP Development Tools)
.buildpath
# sbteclipse plugin
.target
# Tern plugin
.tern-project
# TeXlipse plugin
.texlipse
# STS (Spring Tool Suite)
.springBeans
# Code Recommenders
.recommenders/
# Annotation Processing
.apt_generated/
.apt_generated_test/
# Scala IDE specific (Scala & Java development for Eclipse)
.cache-main
.scala_dependencies
.worksheet
# Uncomment this line if you wish to ignore the project description file.
# Typically, this file would be tracked if it contains build/dependency configurations:
.project
# JDT-specific (Eclipse Java Development Tools)
.classpath
# others
/target/
### Eclipse Patch ###
# Spring Boot Tooling
.sts4-cache/
### Java ###
# 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*
replay_pid*
# End of https://www.toptal.com/developers/gitignore/api/java,eclipse
위의 파일은 gitignore.io라는 사이트에서 java, eclipse 2개의 키워드로 만들었고
추가로 .project 를 주석제거하고 .classpath, /target/을 추가하였습니다.
보통 메이븐 빌드로 인해 생기는 target 디렉토리를 제외 시키기 위해 */target/* 적용을 많이 사용하시는데
저는 */target/*으로 안걸러져서 /target/으로 변경하였습니다. 아래 링크 참조하시면 좋을것 같습니다.
target/ vs /target/ in .gitignore
I am using Eclipse (this is probably irrelevant) and I want to exclude Maven target folder from commit. There are lots of notations /target/** */target/* /target/** target/ /target/ What is the
stackoverflow.com
.project, .classpath, /target/ 3개를 추가적으로 설정하는 이유는 다른 사람들의 PC에 설치된 이클립스 환경설정과 연관되어 있으므로 충돌을 방지하기 위함입니다.