로컬 저장소 생성
git init
특정 파일 staging
git add 파일명
전체 파일 staging
git add .
커밋
git commit
git commt -m '커밋메시지'
staging + commit (최초 커밋에서는 git add + git commit 분리)
git commit -am '커밋메시지'
git add 취소 (커밋 이력 없는 경우)
git rm --cached 파일명
git add 취소 (커밋 이력 있는 경우)
git rm --staged 파일명
git commit 취소
git reset --hard 이전커밋아이디
// 커밋아이디 검색해서 찾아야함
git 상태 확인
git status
git 로그 확인
git log
git log --oneline
git 현재 상태 확인
git show
git 차이 확인
git diff ==word-diff 커밋아이디1 커밋아이디2
브랜치 생성
git branch 브랜치명
브랜치로 전환
git checkout 브랜치명
브랜치 생성 + 전환
git checkout -b 브랜치명
main 브랜치에 특정 브랜치 병합하기 (main 브랜치로 이동한 뒤 작업해야함)
git checkout main
git merge 브랜치명
브랜치 삭제
git branch -d 브랜치명
원격 저장소 등록 (origin)
git remote add origin 저장소주소
원격 저장소 삭제 (origin)
git remote remove origin
원격 저장소 주소 변경 (origin)
git remote set-url origin 변경주소
변경된 주소와 동기화 (origin)
git remote update origin --prune
원격 저장소 이름 바꾸기 (origin -> origin2)
git remote rename origin origin2
원격 저장소 복제하기
git clone 저장소주소
원격 저장소 -> 로컬 저장소 내려받기
git pull origin main
원격 저장소 -> 로컬 저장소 히스토리 없어도 내려받기
git pull origin main --allow-unrelated-histories
로컬 저장소 -> 원격 저장소 올리기
git push origin main
로컬 저장소 -> 원격 저장소 강제로 올리기
git push -f origin main