$ git commit --amend --no-edit --date "$(date)"
$ git commit --amend --no-edit --date "Fri 18 Feb 2022 01:35:10 KST"
REBASE
를 통한 커밋 날짜와 작성한 날짜 변경rebase
를 진행할 커밋 지정$ git rebase -i HEAD~1 # 가장 최근 커밋에 대하여 Rebase 진행
해당 커밋을 수정하기 위해 pick
대신 아래와 같이 edit
명령어로 변경한다.
edit fc27d76 Commit Message
# Rebase 0b1301b..fc27d76 onto 0b1301b (1 command)
#
# Commands:
# p, pick <commit> = use commit
# r, reword <commit> = use commit, but edit the commit message
# e, edit <commit> = use commit, but stop for amending
# s, squash <commit> = use commit, but meld into previous commit
# f, fixup <commit> = like "squash", but discard this commit's log message
# x, exec <command> = run command (the rest of the line) using shell
# b, break = stop here (continue rebase later with 'git rebase --continue')
# d, drop <commit> = remove commit
# l, label <label> = label current HEAD with a name
$ GIT_COMMITTER_DATE= git commit --amend --no-edit --date "Fri 18 Feb 2022 01:35:10 KST"
$ GIT_AUTHOR_DATE= git commit --amend --no-edit --date "Fri 18 Feb 2022 01:35:10 KST"
rebase
종료$ git rebase --continue
저장이 아닌 취소하고자 할 경우 --continue
대신 --abort
옵션을 사용하면 된다.
변경 후
GitHub
내 타임라인의 시간과 커밋 시간이 일치하지 않는 등 불일치한 경우가 발생할 때 아래와 같이 실행한다.$ git filter-branch --env-filter 'export GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"' # 특정 조건을 가진 커밋을 필터링하여 브랜치를 재정의 $ git push -f # 강제(Force) PUSH
* 참고자료: [git-filter-branch Documentation](https://git-scm.com/docs/git-filter-branch)
$ git filter-branch -f --env-filter \
'if [ $GIT_COMMIT = {커밋 Hash값} ]
then
export GIT_AUTHOR_DATE="Fri 18 Feb 2022 01:35:10 KST"
export GIT_COMMITTER_DATE="Fri 18 Feb 2022 01:35:10 KST"
fi'
$ git push origin -f