Last active
November 30, 2019 12:39
-
-
Save rsp9u/0bf7991d62efe70cb6ae4280819aed34 to your computer and use it in GitHub Desktop.
Adjust timestamps of git author date and committer data.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| export FILTER_BRANCH_SQUELCH_WARNING=1 | |
| timediff=$(( $(date -d "2019/11/30 18:28:46" +%s) - $(date -d "Wed Nov 27 08:16:58 2019" +%s) )) | |
| for commit_hash in $(git log --pretty=oneline --author=$1 | cut -d" " -f1); do | |
| git log -n1 $commit_hash --pretty=fuller | |
| author_fixed=$(date -d @"$(( $(date -d "$(git log $commit_hash -n1 --pretty=fuller | grep AuthorDate | cut -d: -f2- | rev | cut -d" " -f2- | rev)" +%s) + $timediff ))" +%s) | |
| commit_fixed=$(date -d @"$(( $(date -d "$(git log $commit_hash -n1 --pretty=fuller | grep CommitDate | cut -d: -f2- | rev | cut -d" " -f2- | rev)" +%s) + $timediff ))" +%s) | |
| echo "author: " $(date -d @"$author_fixed") | |
| echo "commit: " $(date -d @"$commit_fixed") | |
| git filter-branch -f --env-filter " | |
| if [ \$GIT_COMMIT = $commit_hash ] | |
| then | |
| export GIT_AUTHOR_DATE=\"$author_fixed\" | |
| export GIT_COMMITTER_DATE=\"$commit_fixed\" | |
| fi | |
| " | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment