![[Git] commit 날짜 수정](https://cdn.hashnode.com/res/hashnode/image/unsplash/BXOXnQ26B7o/upload/v1649001774804/qICw6f5HU.jpeg)
git rebase -i로 원하는 commit 고르기
git rebase -i --root
위 명령어를 실행하면 vi가 열리는데 원하는 commit을 pick에서 edit으로 바꾸고 :wq로 저장하면 commit이 선택된다.
git log 명령어의 결과를 통해 지금 선택된 commit을 알 수 있다.
commit 날짜 수정하기
git commit --amend --no-edit --date "Mon Mar 28 20:11:36 2022 +0900"
data 부분에 들어갈 날짜를 원하는 날짜 및 시간으로 수정하면 된다.
git rebase --continue
만약 날짜를 바꾸고 싶은 commit이 한 개 이상이라 여러 개를 edit으로 바꾸었다면 git rebase --continue로 다음 commit으로 넘어갈 수 있다.
모종의 이유로 rebase를 멈추고 싶다면
git rebase --abort를 사용하면 된다
다 바뀐게 아니다?
이 부분은 의도된 것이긴 한데 rebase로 commit을 수정하면 AuthorDate는 바뀌지만 CommitDate는 바뀌지 않는다.
git log --pretty=fuller
commit 1347db1ffc44e621d645bd76a52126b3761760d2
Author: Yun Seongmin <ilcm96@gmail.com>
AuthorDate: Mon Mar 28 20:11:36 2022 +0900
Commit: Yun Seongmin <ilcm96@gmail.com>
CommitDate: Sun Apr 3 22:58:16 2022 +0900
Initial commit
위와 같이 AuthorDate는 바뀌었지만 CommitDate는 그대로인 것을 볼 수 있다.
이를 수정하기 위해서는 git filter-branch를 사용해야 한다.
git filter-branch --env-filter 'export GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"'
GIT_COMMITTER_DATE를 GIT_AUTHOR_DATE로 덮어 씌운다는 명령어로 이 명령어를 실행하면 AuthorDate와 CommitDate가 같아지게 된다.
git push
이렇게 변경한건 강제로 push를 해줘야 한다
git push origin +main
위와 같이 브랜치명 앞에 +를 붙이면 강제로 push된다.


![[YSM의 서버 세팅] - Ssl 갱신 자동화](https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/YFFGkE3y4F8/upload/403911f5e0e7609f6c6b0addeb5fef78.jpeg)
![[YSM의 서버 세팅] - Oracle Cloud ARM](https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/v7daTKlZzaw/upload/7d95d24381c2f051a55e244bf2da9992.jpeg)
![[image-optimize] 2. 이미지는 어떻게 최적화 해야할까?](https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/HkM6gUe6CiU/upload/37da18c9528d9b74d7fbf93ef94d4853.jpeg)