C.W.K.
Stream
Lesson 05 of 05 · published

git log와 git diff: 바꾸기 전에 읽기

~24 min · log, diff, inspection

Level 0Untracked 새싹
0 XP0/47 lessons0/14 achievements
0/100 XP to next level100 XP to go0% complete

바꾸기 전에 프로젝트를 읽어

git loggit diff 가 프로젝트를 읽는 방법이야. 입문자는 보통 '내가 뭘 했는지' 확인용으로 써. 프로는 뭐 하기 전 에 써 — 함수가 마지막에 언제 바뀌었는지 찾기, 누구 코드 건드릴지 파악, 변경 범위 잡기, push 전 가설 검증.

git log 만은 verbose 해. 외워둘 모양들: 컴팩트 제목 git log --oneline, DAG 전체 git log --oneline --graph --decorate --all (이건 alias — 하루에 수십 번 써), patch 인라인 git log -p, 파일 변경 요약 git log --stat. 필터: --author, --since/--until, 메시지에 --grep, diff 내용에 -S (pickaxe — 문자열 추가/제거한 commit 찾기), regex 용 -G.

git diff 는 사람들이 아는 것보다 변종이 많아. git diff 단독은 working tree vs index. git diff --staged 는 index vs HEAD. git diff abc..def 는 commit 간 변경. git diff main..feature 는 feature 가 main 에 비해 가진 것 (그 방향만). git diff --stat 은 파일별 요약. git diff --word-diff 는 단어 단위 강조 — 산문이나 minified CSS 같은 긴 줄에 유용.

영원히 보답하는 power move 두 개: git log -p -- path/to/file 는 그 파일을 건드린 모든 commit 을 diff 와 함께 — regression 추적에 완벽. git log -L :functionName:path/to/file 는 한 함수의 history 만 따라가. 진짜 bug 에 처음 써보면 cheat code 발견한 기분이야.

Code

Daily-grade log 주문·bash
# 모든 branch 의 컴팩트 graph (alias 박아!):
git log --oneline --graph --decorate --all

# 파일 하나의 patch 포함 history:
git log -p -- src/auth.js

# 함수 하나의 history (-L 은 token 검색):
git log -L :authenticateUser:src/auth.js

# Pickaxe — 문자열 add/remove 한 commit 찾기:
git log -p -S 'OAUTH_ENABLED'

# author + 날짜 필터:
git log --author="Pippa" --since="2026-04-01" --oneline
의도 있는 diff·bash
# working tree vs index:
git diff

# index vs 마지막 commit:
git diff --staged

# commit 두 개:
git diff abc1234..def5678

# feature 가 main 에 비해 가진 것?
git diff main..feature

# 파일 단위 요약:
git diff main..feature --stat

# 산문 / 긴 줄용 단어 단위:
git diff --word-diff content/cwk-quests/git-quest/data.md

External links

Exercise

여러 번 편집된 실제 파일 하나 골라. git log --oneline -- path 돌리고 commit hash 하나 골라 git show <hash> -- path. 그 다음 git log -p -S 'someStringYouChosen' -- path. 각 query 가 git log --oneline 단독으로는 안 보이던 뭘 보여줬는지 적어.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.