I have a script in my path called git-rcd that changes GIT_COMMITTER_DATE and GIT_AUTHOR_DATE any commit you want (and not just the last one)
#!/bin/bash # commit # date YYYY-mm-dd HH:MM:SS commit="$1" datecal="$2" temp_branch="temp-rebasing-branch" current_branch="$(git rev-parse --abbrev-ref HEAD)" date_timestamp=$(date -d "$datecal" +%s) date_r=$(date -R -d "$datecal") echo "datecal=$datecal => date_timestamp=$date_timestamp date_r=$date_r" if [[ -z "$commit" ]]; then exit 0 fi git checkout -b "$temp_branch" "$commit" GIT_COMMITTER_DATE="$date_timestamp" GIT_AUTHOR_DATE="$date_timestamp" git commit --amend --no-edit --date "$date_r" git checkout "$current_branch" git rebase --autostash --committer-date-is-author-date "$commit" --onto "$temp_branch" git branch -d "$temp_branch"
What allows me is to take the last commit I just made and type:
git rcd @ '1 day ago'
And presto! My last commit was made yesterday.
It changes any commit you want:
git rcd @~2 '1 day ago'
This will only change HEAD~2 (not HEAD~ or HEAD )
The script works even on Windows.
Once the change is done, click (or git push --force if you clicked earlier with the wrong date). And your strip is saved.
source share