좋은 git 커밋 로그 작성법

Joey·2021년 10월 1일
0

참고 (원문): https://chris.beams.io/posts/git-commit/
참고 (한글): https://meetup.toast.com/posts/106

좋은 git 커밋 메시지를 위한 7가지 규칙

  1. 제목과 본문 사이에 한 줄 띄기
  2. 제목은 50자 이내에 작성
  3. 제목은 대문자로 시작
  4. 제목에 마침표 사용 금지
  5. 제목은 명령형으로 작성
  6. 본문은 72자 부근에서 개행하기
  7. 본문은 how보다 what and why로 서술하기

커밋 로그 작성할 때마다 명확한 기준이 없다보니 내 멋대로 작성할 때가 많다. 괜찮은 기준인것 같아 이제부터라도 이 규칙들을 사용하려고 한다.

5. 제목은 명령형으로 작성

좀 더 자세히 봐야 할 곳은 명령형으로 작성 부분인데 핵심 요령은 다음과 같다.

"If applied, this commit will"

위 문장으로 시작한다 생각하고 Commit log를 작성하면 된다.

  • If applied, this commit will refactor subsystem X for readability
  • If applied, this commit will update getting started documentation
  • If applied, this commit will remove deprecated methods
  • If applied, this commit will release version 1.0.0
  • If applied, this commit will merge pull request #123 from user/branch

7. 본문은 how보다 what and why로 서술하기

7번 항목도 중요한 것 같다. 결국 어떠한 작업(commit)은 어떻게 했느냐 보다 왜 했고, 무엇을 했는지가 핵심인 것 같다. 아래는 Bitcoin Core 커밋에 있는 'what changed and why'의 좋은 예제이다.

commit eb0b56b19017ab5c16c745e6da39c53126924ed6
Author: Pieter Wuille <pieter.wuille@gmail.com>
Date:   Fri Aug 1 22:57:55 2014 +0200

   Simplify serialize.h's exception handling

   Remove the 'state' and 'exceptmask' from serialize.h's stream
   implementations, as well as related methods.

   As exceptmask always included 'failbit', and setstate was always
   called with bits = failbit, all it did was immediately raise an
   exception. Get rid of those variables, and replace the setstate
   with direct exception throwing (which also removes some dead
   code).

   As a result, good() is never reached after a failure (there are
   only 2 calls, one of which is in tests), and can just be replaced
   by !eof().

   fail(), clear(n) and exceptions() are just never called. Delete
   them.
profile
Video Software Engineer

0개의 댓글