1. .gitignore 파일 생성
올리고자 하는 프로젝트의 .git 폴더가 있는 경로로 이동 후, .gitignore 파일을 생성해준다.
위치를 반드시 확인하자!
cd /Users/abc/workspace/java
sudo touch .gitignore
2. .gitignore 파일 작성
아래 코드는 Eclipse / Java / macOS 기준이다.
www.toptal.com/developers/gitignore
위 사이트에서 해당하는 환경에 따라 파일 내용을 가져올 수 있다.
# Created by https://www.toptal.com/developers/gitignore/api/macos,eclipse,java
# Edit at https://www.toptal.com/developers/gitignore?templates=macos,eclipse,java
### 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
### 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*
### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
# End of https://www.toptal.com/developers/gitignore/api/macos,eclipse,java
3. .gitignore 파일이 작동하지 않을 때
git의 캐시가 문제되는 것으로 캐시 내용을 전부 삭제한 후 다시 push 하면 된다.
git rm -r --cached .
git add .
git commit -m "fixed untracked files"
git push origin master
'GIT' 카테고리의 다른 글
git push 실패할 때 (0) | 2020.12.30 |
---|---|
Git이란? + 기초 용어 정리 (0) | 2020.12.23 |
GIT에 이클립스 프로젝트 업로드하기 (0) | 2020.11.04 |