feat: add script to automate rewriting commit dates in repository history
This commit is contained in:
@@ -0,0 +1,28 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Define dates
|
||||||
|
DATE1="2016-07-24T12:00:00"
|
||||||
|
DATE2="2020-07-25T12:00:00"
|
||||||
|
DATE3="2020-07-26T12:00:00"
|
||||||
|
DATE4="$(date -Iseconds)" # Today
|
||||||
|
|
||||||
|
# Get commit hashes
|
||||||
|
COMMITS=($(git rev-list --reverse HEAD))
|
||||||
|
|
||||||
|
# Create a temporary branch to work on
|
||||||
|
git checkout -b temp-rewrite
|
||||||
|
|
||||||
|
# Amend each commit
|
||||||
|
GIT_AUTHOR_DATE="$DATE1" GIT_COMMITTER_DATE="$DATE1" git commit --amend --no-edit
|
||||||
|
git cherry-pick ${COMMITS[1]}
|
||||||
|
GIT_AUTHOR_DATE="$DATE2" GIT_COMMITTER_DATE="$DATE2" git commit --amend --no-edit
|
||||||
|
git cherry-pick ${COMMITS[2]}
|
||||||
|
GIT_AUTHOR_DATE="$DATE3" GIT_COMMITTER_DATE="$DATE3" git commit --amend --no-edit
|
||||||
|
git cherry-pick ${COMMITS[3]}
|
||||||
|
GIT_AUTHOR_DATE="$DATE4" GIT_COMMITTER_DATE="$DATE4" git commit --amend --no-edit
|
||||||
|
|
||||||
|
# Switch main to the new history
|
||||||
|
git checkout main
|
||||||
|
git reset --hard temp-rewrite
|
||||||
|
git branch -D temp-rewrite
|
||||||
Reference in New Issue
Block a user