이미 컴퓨터에 생성된 파일이 있는 경우 새로운 레포지토리 생성해서 연결할 때
git init
깃으로 관리하도록 하는 명령어
git remote add origin [깃 주소]
원격저장소에 연결하기
git remote -v
잘 연결됐는지 확인하기
- 연결됐으면 주소가 뜨고 안됐으면 아무것도 안뜸
깃 연동 해제 명령어
git remote remove origin
다시git remote -v
로 확인
git pull origin main
git pull origin main --allow-unrelated-histories
git push origin +main
으로 강제 푸시git add .
git commit -m ""
git push origin main
깃이그노어 파일 수정하기
https://www.toptal.com/developers/gitignore
java, eclipse 등 선택해서 나오는 코드 .gitignore에 붙여넣기
주의 .project .classpath .settings/ 3개는 지워주자!! 원래 설정이 꼬이기 쉬운 부분이라 ignore처리를 해줘야 하지만 처음 등록할 때 이게 없으면 프로젝트 자체를 못찾을 수 있기 때문에 일단 지워주고 복사하자
참고한 블로그
# Created by https://www.toptal.com/developers/gitignore/api/eclipse,java
# Edit at https://www.toptal.com/developers/gitignore?templates=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*
replay_pid*
# End of https://www.toptal.com/developers/gitignore/api/eclipse,java
git rm -r --cached .
gitignore에 올린다고 바로 적용되지는 않는다
깃에서 이미 추적하고 있던 파일들의 상태는 변하지 않기 때문에 캐시를 삭제해야 한다.
이후 add, commit까지 하면 깃이그노어 파일 내용이 적용된다.