Git Commit Message Convention

jiyoon·2023년 8월 17일
0

Git Commit Message Convention

사전 지식

1). Git Commit Convention 이란?

  1. 커밋 메시지에 대한 약속이며 커밋 메시지를 작성할 때는 원칙을 정하고 일관성 있게 작성해야 한다.

  2. 커밋 메시지 구조는 크게 3가지로 나뉜다 (제목, 본문, 꼬리말)

2). Commit Message 구조

  • 제목, 본문, 꼬리말

    type: Subject -> 제목
    (한칸 띄우기)
    body(생략 가능) -> 본문
    (한칸 띄우기)
    footer(생략 가능) -> 꼬리말



3). Subject

  • 제목은 50글자 이내로 작성한다.

  • 첫글자는 대문자로 작성한다.

  • 마침표 및 특수기호는 사용하지 않는다.

  • 영문으로 작성하는 경우 동사(원형)을 가장 앞에 명령어로 작성한다.

  • 과거시제는 사용하지 않는다.

  • 간결하고 요점적으로 즉, 개조식 구문으로 작성한다.


예시 )

Fixed --> Fix 

Added --> Add

Modified --> Modify 



4). Body

  • 72자를 넘기지 않고 제목과 구분되기 위해 한칸을 띄워 작성한다.

  • 코드 변경의 이유를 명확히 작성한다. (어떻게 변경했는지보다 무엇을, 왜 변경했는지 작성한다.)

  • 선택사항이기 때문에 모든 커밋에 본문내용을 작성할 필요는 없다.



  • issue tracker id를 명시하고 싶은 경우에 사용한다.

  • 유형 : #이슈 번호 형식으로 작성한다.

  • 여러 개의 이슈번호는 쉼표(,)로 구분한다.

  • 이슈 트래커 유형은 다음 중 하나를 사용한다.

  • 선택사항이기 때문에 모든 커밋에 꼬리말을 작성할 필요는 없다.


Fixes : 이슈 수정중(아직 해결되지 않은 경우)

Resolves : 이슈를 해결했을 때 사용

Ref : 참고할 이슈가 있을 때 사용

Related to : 해당 커밋에 관련된 이슈번호 (아직 해결되지 않은 경우)

예시 )

Fixes: #45 Related to: #34, #23



  • 추가적인 문맥 정보를 제공하기 위한 목적으로 괄호안에 적을 수도 있다.

예시 )

Feat(navigation) : 

Fix(db) :



6). Commit Type

  • 커밋의 타입 구성

    • Feat : 새로운 기능 추가


    • Fix : 버그 수정


    • Update : Fix와 달리 원래 정상적으로 동작했지만 보완의 개념으로 사용


    • Refactor : 리팩토링


    • Simplify : Refator와 유사하지만 약한 수정, 코드 단순화


    • Correct : 주로 문법의 오류나 타입의 변경, 이름 변경 등에 사용


    • Improve : 호환성, 테스트 커버리지, 성능, 검증 기능, 접근성 등의 향상


    • Design : CSS 등 사용자 UI 디자인 변경


    • Comment : 필요한 주석 추가 및 변경


    • Style : 코드 포맷팅, 세미콜론 누락, 코드 변경이 없는 경우


    • Test : 테스트 (테스트 코드 추가, 수정, 삭제, 비즈니스 로직에 변경이 없는 경우)


    • Docs : 문서 수정


    • Chore : 기타 변경 사항 (빌드 스크립트 수정, assets image, 패키지 매니저 수정, Production Code 변경 등)


    • Init : 프로젝트 초기생성


    • !BREAKING CHANGE : 커다란 API 변경의 경우


    • !HOTFIX : 급하게 치명적인 버그를 고쳐야하는 경우


    • Rename : 파일 혹은 폴더명을 수정하거나 옮기는 경우


    • Remove : 파일을 삭제하는 작업만 수행하는 경우


    • Move : 코드나 파일의 이동




7). Example

  • example 1
Feat: 회원 가입 기능 구현

SMS, 이메일 중복확인 API 개발

Resolves: #123
Ref: #456
Related to: #48, #45
  • example 2
feat: Summarize changes in around 50 characters or less

More detailed explanatory text, if necessary. Wrap it to about 72
characters or so. In some contexts, the first line is treated as the
subject of the commit and the rest of the text as the body. The
blank line separating the summary from the body is critical (unless
you omit the body entirely); various tools like `log`, `shortlog`
and `rebase` can get confused if you run the two together.

Explain the problem that this commit is solving. Focus on why you
are making this change as opposed to how (the code explains that).
Are there side effects or other unintuitive consequences of this
change? Here's the place to explain them.

Further paragraphs come after blank lines.

- Bullet points are okay, too

- Typically a hyphen or asterisk is used for the bullet, preceded
by a single space, with blank lines in between, but conventions
vary here

If you use an issue tracker, put references to them at the bottom,
like this:

Resolves: #123
See also: #456, #789

참고 1 : https://doublesprogramming.tistory.com/256
참고 2 : https://velog.io/@archivvonjang/Git-Commit-Message-Convention
참고 3 : https://kdjun97.github.io/git-github/commit-convention/

profile
한걸음 나아가는 개발자

0개의 댓글