# 원격 저장소 클론
git clone https://github.com/username/repository.git
# 디렉토리 이동
cd repository-name
# 새 브랜치 생성 + 전환
git checkout -b branch-name
# 또는 (Git 2.23+)
git switch -c branch-name
# 변경사항 추가
git add .
# 커밋
git commit -m "커밋 메시지"
# 원격 저장소에 푸시
git push origin branch-name
git checkout main # main 브랜치로 전환
git pull origin main # 최신 main 가져오기
git checkout study/01-project-setup # 작업 브랜치로 복귀
git pull origin main # 작업 브랜치도 최신화
git status # 현재 변경사항 확인
git branch # 로컬 브랜치 목록
git branch -r # 원격 브랜치 목록
git log --oneline -5 # 최근 5개 커밋 확인
git diff # 현재 변경사항 확인
git diff --staged # 스테이지된 변경사항 확인
git log --oneline --graph # 커밋 그래프 확인
git checkout -b new-branch # 새 브랜치 생성 + 전환
git checkout existing-branch # 기존 브랜치로 전환
git switch branch-name # 브랜치 전환 (Git 2.23+)
git branch -d branch-name # 로컬 브랜치 삭제
git push origin -d branch-name # 원격 브랜치 삭제
git add . # 모든 변경사항 스테이지
git add filename # 특정 파일만 스테이지
git commit -m "메시지" # 커밋
git commit -am "메시지" # 추가 + 커밋 (신규 파일 제외)
git commit --amend -m "새 메시지" # 마지막 커밋 메시지 수정
git reset HEAD~1 # 마지막 커밋 취소 (변경사항 유지)
git reset --hard HEAD~1 # 마지막 커밋 완전 삭제
git push origin branch-name # 브랜치 푸시
git push origin main # main 브랜치 푸시
git pull origin main # main 브랜치 풀
git fetch origin # 정보만 가져오기 (머지 안함)
git remote -v # 원격 저장소 목록
git remote add origin url # 원격 저장소 추가
git log # 전체 커밋 로그
git log --oneline # 한 줄로 요약
git log --oneline -10 # 최근 10개만
git log --graph --all # 그래프로 모든 브랜치
git log filename # 특정 파일 변경 이력
git blame filename # 각 줄의 작성자 확인
git show commit-hash # 특정 커밋 상세 정보
cd /Users/moon/Desktop/study-insupanda
git status
git checkout main
git pull origin main
git checkout study/01-project-setup
git pull origin main
git add .
git commit -m "docs: Phase X.Y [작업내용] 완료"
git push origin study/01-project-setup
git checkout main
git pull origin main
git checkout -b phase1-3-env-config
# 작업 진행
git add .
git commit -m "docs: Phase 1.3 환경설정 파일 분석 완료"
git push origin phase1-3-env-config
# 학습 프로젝트용
git commit -m "docs: Phase X.Y [작업내용] 완료"
git commit -m "study: [학습내용] 정리 완료"
git commit -m "analysis: [분석내용] 완료"
# 일반 프로젝트용
git commit -m "feat: 새로운 기능 추가"
git commit -m "fix: 버그 수정"
git commit -m "refactor: 코드 리팩토링"
# 충돌 발생 시
git status # 충돌 파일 확인
# 파일 수동 편집 후
git add .
git commit -m "resolve: merge conflict 해결"
git reset HEAD filename # 스테이지 취소
git checkout -- filename # 파일 변경사항 취소
git reflog # 참조 로그 확인 (복구용)
git fetch origin
git reset --hard origin/main # 로컬을 원격과 완전 동일하게
git status && git pull origin main
git add . && git commit -m "메시지" && git push origin branch-name
git branch -d old-branch && git push origin -d old-branch
git config --global alias.st status
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.cm commit
git config --global alias.ps push
git config --global alias.pl pull
git config --global alias.lg "log --oneline --graph"
git st # git status
git co main # git checkout main
git cm "메시지" # git commit -m "메시지"
git lg # 예쁜 로그
git stash # 현재 작업 임시 저장
git stash pop # 임시 저장된 작업 복구
git stash list # 저장된 작업 목록
git reflog # 모든 참조 로그 확인
git checkout -b 브랜치명 커밋해시 # 특정 지점에서 브랜치 생성
gh pr create --title "제목" --body "내용"
gh pr list # PR 목록
gh pr view # PR 상세 보기
git checkout main
git pull origin main
git checkout -b phase2-1-config
git stash # 현재 작업 임시 저장
git checkout main
git pull origin main
git checkout my-branch
git pull origin main # 최신 main 반영
git stash pop # 작업 복구
git checkout main
git pull origin main
git branch -d merged-branch # 로컬 브랜치 삭제
git push origin -d merged-branch # 원격 브랜치 삭제
git status 현재 상태 확인git pull origin main 최신 상태 동기화git add . 변경사항 스테이지git push origin branch-name 푸시💡 TIP: 이 치트시트를 즐겨찾기하고 필요할 때마다 참고하세요!