알아두기
commit 작성 시간 임의로 지정하기
git add README.md
GIT_AUTHOR_DATE="2023-12-28 12:00:00 KST" GIT_COMMITTER_DATE="2023-12-28 12:00:00 KST" git commit -m "Update README.md"
# GIT_COMMITTER_DATE="2023-12-28 12:00:00 KST" git commit --date="2023-12-28 12:00:00 KST" -m "Update README.md"
GIT_COMMITTER_DATE
: git commit 시간 수정
GIT_AUTHOR_DAT
or --date
: AuthorData 수정
최신 commit의 시간 수정
GIT_COMMITTER_DATE="11 Feb 2023 09:25:12 KST" git commit --amend --date "11 Feb 2023 09:25:12 KST" --no-edit
# 시간 format은 "2023-02-11 09:25:12 KST"도 가능
GIT_COMMITTER_DATE
: git commit 시간 수정
--amend
: 최신 commit 수정
--date
: AuthorData 수정
--no-edit
: 시간만 수정할 경우
과거 여러 commit들의 시간 수정
# 최근 commit 4개 수정시
git rebase -i HEAD~4
# 모든 commit 수정시
git rebase -i --root
- rebaes 시 해당 commit들 list가 뜨며, pick으로 설정되어있음. 내가 수정할 것을 e로 수정하고
:wq
(vim 이용시)로 저장후 종료
pick e6744cf Initial commit
e g86d471 add test1 # 수정할 commit을 e로 변경
pick 6cf03ea add test2
e efea9f6 add test3 # 수정할 commit을 e로 변경
# Rebase 12e9c34..efea9f6 onto 12e9c34 (4 commands)
#
# 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 [-C | -c] <commit> = like "squash" but keep only the previous
# commit's log message, unless -C is used, in which case
# keep only this commit's message; -c is same as -C but
# opens the editor
# 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
# t, reset <label> = reset HEAD to a label
# m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]
# . create a merge commit using the original merge commit's
# . message (or the oneline, if no original merge commit was
# . specified); use -c <commit> to reword the commit message
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.