programing

'commit date'를 표시하도록 'git log'를 구성하는 방법

showcode 2023. 6. 19. 21:48
반응형

'commit date'를 표시하도록 'git log'를 구성하는 방법

구성 방법git log보여주기 위해commit date대신에author date?

날짜를 예쁘게 인쇄할 수 있는 몇 가지 옵션이 있습니다.아마도 가장 쉬운 방법은 미리 구운 것 중 하나를 사용하는 것입니다.--pretty형식, 예를 들어git log --pretty=fuller두 날짜가 모두 표시됩니다.날짜를 하나만 표시하고 커밋 날짜로 지정하려면 다음을 사용할 수 있습니다.git log --format=<some stuff>형식을 정의할 수 있는 모든 코드는 다음에 문서화되어 있습니다.git help log커밋 날짜는 다음 중 하나입니다.%cd,%cD,%cr,%ct또는%ci원하는 형식에 따라 달라집니다.

자주 하고 싶은 일이라면 별칭에 넣거나 보조 스크립트를 작성하여 타이핑 비용을 절약합니다.

사용할 수 있습니다.--pretty=format및 사용%cr커밋 날짜 상대에 대해.

예:

$ git log --graph --pretty=format:'%C(auto)%h%d (%cr) %cn <%ce> %s'

사용하기 쉽도록 별칭을 정의할 수 있습니다.내 안에는 다음이 있습니다..gitconfig:

[alias]
# see `git help log` for detailed help.
#   %h: abbreviated commit hash
#   %d: ref names, like the --decorate option of git-log(1)
#   %cn: commiter name
#   %ce: committer email
#   %cr: committer date, relative
#   %ci: committer date, ISO 8601-like format
#   %an: author name
#   %ae: author email
#   %ar: author date, relative
#   %ai: author date, ISO 8601-like format
#   %s: subject
# my awesome git log replacement
lol  = log --graph --pretty=format:\"%C(auto)%h%d%Creset %C(cyan)(%cr)%Creset %C(green)%cn <%ce>%Creset %s\"
# same as above, but ISO date
lold = log --graph --pretty=format:\"%C(auto)%h%d%Creset %C(cyan)(%ci)%Creset %C(green)%cn <%ce>%Creset %s\"
# using build-in standards
lol2 = log --oneline --graph --decorate
# shows branches and their last commits
lol3 = log --all --graph --decorate --oneline --simplify-by-decoration

Linux 또는 유사한 시스템에서는 단일 따옴표를 사용할 수 있습니다.'쌍끌이 대신에":

[alias]
lol = log --graph --pretty=format:'%C(auto)%h%d%Creset %C(cyan)(%cr)%Creset %C(green)%cn <%ce>%Creset %s'

이것으로, 간단히 실행합니다.git lol또는 다른 변형을 통해 예쁜 출력을 확인할 수 있습니다.

의 결과는 다음과 같습니다.git lol --simplify-by-decoration:

git lol output

  • 좋아 보여요.:)
  • lol보다 입력하기 쉽습니다.log그리고 더 좋게 들립니다.
    • 또한 정기적으로 액세스할 수 있습니다.git log언제든 필요하면요
  • 당신의 눈은 다양한 색으로 내용물을 빠르게 스캔할 수 있습니다.
  • 이름과 이메일은 많은 기여자가 있는 대규모 프로젝트/조직에 매우 유용합니다.
  • 해시/ref에 기본 색상을 사용하는 것은 이미 꽤 좋기 때문입니다.

의 결과는 다음과 같습니다.git lold날짜가 ISO 형식으로 표시됩니다.기여자의 시간대를 쉽게 볼 수 있다는 이점과 함께 커밋이 이루어진 정확한 날짜/시간을 확인하는 데 유용합니다.

enter image description here

2020-06 편집: 스크린샷 추가.사용하도록 업데이트됨%C(auto)(자동/기본 색상):%h(커밋 해시) 및%d(이름 변경).추가된%cn(커미셔너 이름)과 이메일을 함께 제공합니다.

작성자 이름을 포함하지 않고 실제 커밋 날짜를 포함하는 이 형식을 선호합니다.

git log --graph --pretty=format:"%C(yellow)%h%x09%Creset%C(cyan)%C(bold)%ad%Creset  %C(green)%Creset %s" --date=short

누군가에게 유용할 수도 있습니다.작가 이름이 적힌 날짜와 타임 스탬프를 찾고 있었습니다.

enter image description here

git log --graph --pretty=format:"%C(yellow)%h%x09%Creset%C(cyan)%C(bold)%ad%Creset %C(yellow)%cn%Creset  %C(green)%Creset %s" --date=default

언급URL : https://stackoverflow.com/questions/14243380/how-to-configure-git-log-to-show-commit-date

반응형