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

비난 없는 blame

~18 min · blame, history

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

blame 은 forensics 지 비난 아니야

이름이 안타깝게 손가락질을 암시. 실제 사용 사례는 forensics: 이 줄을 도입한 commit 이 뭐, 어떤 맥락, 어떤 메시지, 같이 들어온 다른 줄은? git blame 이 다 답. 잘 쓰면 코드가 왜 이 모양인지 이해하는 가장 빠른 방법 — 그리고 그걸 정당화하는 대화 찾는 두 번째로 빠른 방법.

git blame file.js 출력은 source 줄당 한 줄: commit hash (short), author, 날짜, 줄 번호, 줄 내용. 각 줄이 그 줄을 건드린 가장 최근 commit 알려줘. 거기서 git show <hash> 가 full commit 열어 — 메시지, full diff, 결정적으로 그 변경들이 같이 일어난 이유 설명. Blame 줄이 진입점, commit 메시지와 주변 diff 가 증거.

가장 흔한 짜증 해결하는 flag 둘. git blame -w 가 whitespace-only 변경 무시. git blame -M 이 같은 파일 내 이동된 코드 따라감 (-M -M 으로 파일 간 이동). 없으면 reformat 만 하거나 함수 옮긴 refactor 가 전체 영역의 blame 을 refactor commit 가리키게 만들어, 원래 의도 숨김. 있으면 blame 이 기계적 churn 을 지나 실제 logic 도입 commit 으로.

프로 동작: git log -L :functionName:file.js. 프로젝트 전체에서 함수 하나의 history 표시 — 그 함수를 바꾼 모든 commit, 시간순, diff 와 함께. 함수 진화 보임. '이 메서드 동작이 언제 바뀌었지?' 또는 '왜 이 validation 이 여기 있지?' 추적엔 git log file.js 후 함수 건드렸는지 각 commit 열기보다 극적으로 빨라. Muscle memory 에 추가.

Code

제정신 flag 와 함께 blame 기본·bash
# Default blame (refactor 많은 파일엔 짜증):
git blame src/auth.js

# 유용 — whitespace 무시 + 파일 내 이동 따라감:
git blame -w -M src/auth.js

# 파일 간 이동 + 복사 (느리지만 철저):
git blame -w -C -C src/auth.js

# 40-60 줄만:
git blame -L 40,60 src/auth.js

# 특정 날짜 이전 commit 으로 제한:
git blame --before="2026-04-01" src/auth.js
git log -L 로 함수 history·bash
# src/auth.js 의 authenticateUser() 전체 history 추적:
git log -L :authenticateUser:src/auth.js

# src/auth.js 의 40-60 줄 history 추적:
git log -L 40,60:src/auth.js

# 특정 blame 줄 건드린 가장 최근 commit 열기:
git show $(git blame -L 42,42 src/auth.js | awk '{print $1}')

External links

Exercise

1년 이상 된 활성 프로젝트 파일 하나 골라. Flag 없이 git blame, 그 다음 -w -M 으로 noise 레벨 비교. 특정 한 줄에 대해 hash 를 git show 로 따라가 commit 메시지 읽어 — 메시지가 그 줄을 실제로 설명했는지 적어. 같은 파일의 함수에 git log -L 시도 + 뭐 보여줬는지 적어.

Progress

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

댓글 0

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

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