Git

Git 커밋 메시지 변경시 현재 시간으로 바뀌는 현상 해결방법

moxie2ks 2025. 2. 13. 18:01
728x90
반응형

개요

git --amend, git --cherry-pick 또는 git -am 커맨드를 수행할 때 각 commit의 원래 작업된 시간이 아닌 커맨드를 수행했던 시간이 표시될 때가 있다. 이 현상의 원인은 Git에는 author date와 commit date가 따로 존재하기 때문이다. Git은 기본적으로 commit의 시간을 표시할 때 commit date가 아닌 author date를 기본적으로 사용하고 있다.

author date & commit date

author date

original commit이 만들어졌을 때 생성된 시각

commit은 git –amend로는 변경되지 않는다.

commit date

commit이 수정될 때마다 해당 시각으로 업데이트된다.

해결방법

commit date를 기준으로 author date도 동일한 시간으로 만들기

아래 커맨드를 사용하여 author date를 commit date와 동일하게 만들 수 있다.

$ git am -3 **--committer-date-is-author-date** <Path to patch dir>/<file name>.patch

참고 문헌

git commit date & author date

https://stackoverflow.com/questions/69211699/github-commit-date-and-author-date

728x90
반응형