hyelie
hyelie
Hyeil Jeong
       
글쓰기    관리    수식입력
  • 전체보기 (495)
    • PS (283)
      • Algorithm (28)
      • PS Log (244)
      • Contest (6)
      • Tips (5)
    • Development (52)
      • Java (14)
      • Spring (23)
      • SQL (2)
      • Node.js (2)
      • Socket.io (3)
      • Study (4)
      • Utils (4)
    • DevOps (36)
      • Git (5)
      • Docker (4)
      • Kubernetes (2)
      • GCP (3)
      • Environment Set Up (8)
      • Tutorial (12)
      • Figma (2)
    • CS (74)
      • OOP (7)
      • OS (24)
      • DB (2)
      • Network (24)
      • Architecture (0)
      • Security (2)
      • Software Design (0)
      • Parallel Computing (15)
    • Project (15)
      • Project N2T (5)
      • Project ASG (0)
      • Project Meerkat (1)
      • Model Checking (7)
      • Ideas (2)
    • 내가 하고싶은 것! (34)
      • Plan (16)
      • Software Maestro (10)
      • 취준 (8)
hELLO · Designed By 정상우.
hyelie

hyelie

DevOps/Git

[Git] git commit template 적용

Commit Conventions

https://www.conventionalcommits.org/en/v1.0.0/

 

Conventional Commits

A specification for adding human and machine readable meaning to commit messages

www.conventionalcommits.org

 

협업 시, commit할 때 commit message만으로도 코드 수정 내용을 유추할 수 있게 작성해야 한다. 그렇게 하면 코드 리뷰할 때도 편하고, 이슈 트래킹, 티켓 트래킹할 때도 편해진다. 따라서 commit 시에는 규칙을 지켜 작성해야 한다.

 

git commit -m "commit message 내용...
commit message 본문...
commit message 본문..."

그러나 위와 같은 형식으로 CLI에서 작성하고 있으면 답답한 부분이 많다. 적다가 윗 줄을 고치고 싶으면 다시 적어야 하기도 한다. tag나 제목 길이같은 convention도 지키기 어렵다. 이 문제는 commit template를 사용하면 된다.

 

 

Commit Template

커밋 템플릿 .gitmessage.txt 생성

먼저 .gitmessage.txt 파일을 생성한다. 원하는 위치에 생성하면 된다. 나의 경우 아래의 형식으로 만들었다. #는 주석이다. 

################ 제목 ################
# [header tag] : [title]
# [content]
# 의 형식으로 제목을 아래 공백줄에 작성
# 제목은 50자 이내 / 무엇을 했는지 명확히 작성 / 끝에 마침표 금지
# 예) feat : Add login feature
################################################## (50자)


################ 본문 ################
# 여러 줄의 메시지를 작성할 땐 개행으로 구분 (한 줄은 72자 이내)
######################################################################## (72자)


################ 태그 ################
# feat : 새로운 기능 추가
# fix : 버그 수정
# BREAKING CHANGE : 기능적으로 큰 변화가 있는 커밋
# docs : 문서 수정
# test : 테스트 코드 변경
# refactor : 코드 리팩토링
# style : 코드 의미에 영향을 주지 않는 변경사항

 

.gitmessage.txt를 commit template로 지정

아래 명령어를 입력해서 방금 만든 gitmessage.txt 파일을 commit template로 지정한다.

git config --global commit.template [.gitmessage.txt 경로]/.gitmessage.txt

 

commit template 사용

이제 git commit -m "[내용]" 대신, git commit을 입력하면 .gitmessage.txt 템플릿이 나타난다. 그곳에 commit 내용을 작성하면 된다!

'DevOps > Git' 카테고리의 다른 글

[Git] 개발 규칙 정하기 - Kanban과 commit 규칙  (0) 2022.11.01
[Git] git mirroring 하기  (0) 2022.10.05
[Git] 현업에서 사용하는 git  (0) 2022.10.04
[Git] 깃랩 gitlab  (0) 2022.10.04
    hyelie
    hyelie

    티스토리툴바