git log 화려하게 설정하기

git log의 옵션을 통하여 커밋 히스토리를 예쁘게 꾸며보는 것에 관한 글입니다.

git cli에서 기본 제공되는 히스토리 조회 명령어git log 입니다. 기본적인 커밋 로그에 대해 확인할 수 있지만, Github, Bitbucket에서 보여주는 알록달록한 그래프의 형태는 나오지 않습니다.

~/.gitconfig 파일을 통해 git의 설정을 변경할 수 있습니다.

첫번째 강의 챕터에서 기본 브랜치를 main 으로 변경한 내용도 아래의 내용처럼 이 파일에서 관리하게 됩니다.

[init]
        defaultBranch = main

아래에 alias 로 별칭을 두어 커맨드를 만들 수 있습니다.

[alias]
        lg2 = log --graph --abbrev-commit --decorate --format=format:'%C(cyan)%h%C(reset) - %C(green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(yellow)%d%C(reset)' --all
        lg = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n''          %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all
        lg3 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
        

아래 이미지는 lg 커맨드를 실행했을때 나오는 예시입니다

Last updated

Was this helpful?