본문으로 건너뛰기

Day 1 - Git 기초

설치 · 설정 · 첫 커밋 · 상태 확인

목차


학습 목표

  • Git이 왜 필요한지 설명
  • init / add / commit / status / log 사용
  • 작업 트리 · 스테이징 · 커밋 영역 구분

설치

# macOS
brew install git

# 확인
git --version

초기 설정

git config --global user.name "Your Name"
git config --global user.email "you@example.com"
git config --global init.defaultBranch main
git config --global core.editor "code --wait" # 선택
git config --list --show-origin | head

저장소 만들기

mkdir demo-git && cd demo-git
git init
echo "# Demo" > README.md
git status

기본 워크플로

작업 디렉터리 → git add → 스테이징 → git commit → 로컬 히스토리
git add README.md
# 또는 전체
git add .

git commit -m "docs: add README"
git log --oneline
git status

자주 쓰는 명령

명령의미
git status변경·스테이징 상태
git diff스테이징 전 차이
git diff --staged스테이징된 차이
git restore <file>작업 트리 되돌리기
git restore --staged <file>스테이징 취소

실습

  1. 새 폴더에서 git init
  2. 파일 2개 추가 후 각각 커밋 (의미 있는 메시지)
  3. git log --oneline --graph 로 히스토리 확인

관련 문서

그래프 뷰

그래프 데이터 로딩 중…
현재: Day 1 - Git 기초
노드 클릭 → 이동 · 드래그 → 위치 조정