우아한 테크코스 8기 프리코스 1주차[1] - git commit convention

BrokenFinger98·2025년 10월 14일

우아한 테크코스

목록 보기
2/5

프리코스 1주차 문제를 받았다.
AngularJS Git Commit Message를 기준으로 git commit을 작성하라고 되어있어서, 해당 문서를 읽고, Commit Template를 만들어 보려고 한다.

Commit Message 구조

<type>(<scope>): <subject>
blank
<body>
blank
<footer>

예시

feat(member): change member API response structure

Refactored the MemberResponse DTO to include nested profile information
and remove deprecated 'nickname' field. This improves data consistency
between member and profile domains.

BREAKING CHANGE: MemberResponse field 'nickname' has been removed and replaced
with 'profile.nickname'. All client applications must update their response
mapping logic accordingly.

Closes #128

제목

제목은 type(scope): subject 구조로 이루어져있다.

feat(member): change member API response structure

type

  • feat (feature)
  • fix (bug fix)
  • docs (documentation)
  • style (formatting, missing semi colons, …)
  • refactor
  • test (when adding missing tests)
  • chore (maintain)

scope

  • 커밋 변경 사항의 위치를 지정하는 무엇이든 가능
  • 선택적으로 작성 가능
    ex) $location, $browser, $compile, $rootScope, ngHref, ngClick, ngView, etc...

subject

  • 명령형, 현재 시제를 사용
  • 첫 글자를 소문자
  • 마침표 금지

body (본문)

  • 변경 이유, 목적, 이전 동작과의 차이를 명확히 설명
  • 명령형, 현재 시제 사용 ("change" not "changed")
  • 100자 이내로 작성
  • 선택적으로 작성 가능
Refactored the MemberResponse DTO to include nested profile information
and remove deprecated 'nickname' field. This improves data consistency
between member and profile domains.
  • 선택적으로 작성 가능
  1. Breaking Change가 있을 경우
  2. 관련 이슈가 있을 경우
BREAKING CHANGE: MemberResponse field 'nickname' has been removed and replaced
with 'profile.nickname'. All client applications must update their response
mapping logic accordingly.

Closes #128

Breaking Change

  • 이 커밋 이후로 이전 버전과 호환되지 않게 되는 변경사항을 의미
  • 기존 코드나 API를 그대로 쓰던 사용자가 에러를 겪거나, 코드가 깨질 가능성이 있는 경우

1. API 변경

Before: User findById(Long id)
After: User findById(UUID id)

이 커밋을 적용하면 Long 타입으로 호출하던 기존 코드가 전부 깨지게 됨.

2. API 삭제 / 이름 변경

Before: fun getUserInfo()
After: fun fetchUserInfo()

이 커밋을 적용하면 이전 함수를 호출하던 부분은 전부 컴파일 에러

Closes

  • 이 커밋이 어떤 이슈를 해결했는지 연결하고 싶은 경우
  • 여러 이슈 작성 가능

.gitmessage.txt

매번 Commit 메세지를 작성하면 귀찮기도 하고 가끔 Commit Convention이 생각나지 않는 경우를 대비해 .gitmessage.txt를 만들어보려고 합니다.

# <type>(<scope>): <subject>
# ------------------------------------------------------------
# <type>  : feat | fix | docs | style | refactor | test | chore
# <scope> : 변경된 모듈/도메인/패키지/기능명 (선택)
# <subject> : 명령형, 현재 시제, 첫 글자 소문자, 문장부호 X
#
# 예시:
# feat(member): change member API response structure
# fix(user): prevent null pointer on user deletion
# docs(readme): update usage examples
# ------------------------------------------------------------

<type>(<scope>): <subject>

# ------------------------------------------------------------
# BODY (선택 사항)
# ------------------------------------------------------------
# - 변경 이유, 목적, 이전 동작과의 차이를 명확히 설명
# - 명령형, 현재 시제 사용 (“change” not “changed”)
# - 100자 이내로 작성
#
# 예시:
# Refactored the MemberResponse DTO to include nested profile information
# and remove deprecated 'nickname' field. This improves data consistency
# between member and profile domains.
# ------------------------------------------------------------

<body>

# ------------------------------------------------------------
# FOOTER (선택 사항)
# ------------------------------------------------------------
# 1️⃣ Breaking Change가 있을 경우:
# BREAKING CHANGE: <무엇이 어떻게 바뀌었는지, 마이그레이션 방법>
#
# 예시:
# BREAKING CHANGE: removed onHashChange in favor of onUrlChange
#
# 2️⃣ 관련 이슈가 있을 경우:
# Closes #123
# Closes #45, #67
# ------------------------------------------------------------

<footer>

# ------------------------------------------------------------
# ⚠️ 주의
# ------------------------------------------------------------
# - 각 줄은 100자를 넘지 말 것
# - subject는 한 줄로 간결하게 작성
# - body와 footer는 비워둘 수 있음
# - git commit -t .gitmessage.txt 로 미리보기 가능
# ------------------------------------------------------------

적용

개별 적용

.gitmessage.txt를 적용하고 싶은 프로젝트로 이동 후, .gitmessage.txt를 생성한 후, git config commit.template .gitmessage.txt를 적용하면 됩니다.

전역 적용

.gitmessage.txt를 생성한 후, git config --global commit.template ~/.gitmessage.txt 를 적용하면 됩니다.

profile
나는야 개발자

0개의 댓글