(이 포스트는 코딩애플님의 "매우쉽게 알려주는 git&github" 강의내용을 제가 보려고 정리해둔 글입니다.)
1. git add, commit으로 파일 기록하기
2. git add, commit, diff 쉽게 하는 법
3. branch
4. merge (3-way, fast-forward, squash, rebase)
5. reset (git revert, reset, restore)
6. push
파일 복구
git restore 파일명
특정 commit 시점으로 파일 복구
git restore --source 커밋아이디 파일명
staging 취소
git restore --staged 파일명
commit 취소 (여러개 가능)
git revert 커밋아이디1 커밋아이디2
최근 commit 취소
git revert HEAD
reset (모든 작업물 과거로 돌리기)
git reset --hard 커밋아이디
reset (변동사항 staging한 상태로 과거로 돌리기)
git reset --soft 커밋아이디
reset (변동사항 지우지말고 unstage)
git reset --mixed 커밋아이디
기본 명령어
git push -u 원격저장소주소 올릴로컬브랜치명
(기본 명령어가 길어서 변수문법 사용)
원격저장소주소를 origin이라는 변수에 담음
git remote add origin 원격저장소주소
짧아진 명령어
git push -u origin master
(-u : 주소를 기억해라)
더 짧아진 명령어
git push