·터미널 명령어

git blame

git

쓰는 꼴

git blame [-L <start>,<end>] <file>

한 줄 한 줄 마지막으로 고친 커밋을 붙여 보여줍니다 — 서식만 바꾼 커밋이 진짜 저자를 가리므로 -w와 --ignore-rev가 있습니다.

자주 쓰는 옵션

옵션
-L <a>,<b>only those lines
-wignore whitespace, so re-indenting stops hiding the author
-Cfollow code moved in from another file
--ignore-rev <rev>skip a commit, e.g. a bulk reformat
-eshow email addresses instead of names
-sdrop the author and date columns

예시

git blame -L 40,60 src/app.ts

who last touched lines 40 to 60

git blame -w -C src/app.ts

looks past whitespace and moved code

git blame --ignore-rev 9f3c2ab src/app.ts

ignores the commit that reformatted everything

되돌리는 방법이 여럿이라 헷갈립니다 — 가리키는 곳을 옮기는 것과 새 커밋을 얹는 것은 다릅니다.

읽는 방법

  • 대괄호 [ ]는 넣어도 되고 안 넣어도 되는 자리입니다.
  • 점 셋 …은 여러 개를 이어 쓸 수 있다는 뜻입니다.
  • 옵션은 대소문자를 가립니다 — -r과 -R이 다른 명령도 있습니다.

자주 묻는 것

Q. git blame은 무엇을 하나요?

한 줄 한 줄 마지막으로 고친 커밋을 붙여 보여줍니다 — 서식만 바꾼 커밋이 진짜 저자를 가리므로 -w와 --ignore-rev가 있습니다.

Q. 어떻게 치나요?

git blame [-L <start>,<end>] <file> — 대괄호는 생략할 수 있는 자리입니다.

Q. 옵션은 몇 개나 자주 쓰나요?

여기 정리한 것은 6개입니다. 전체 목록은 man git에 있습니다. 이 명령은 git 갈래입니다.

같이 보는 명령

man 페이지: man git-blame