Skip to content

Instantly share code, notes, and snippets.

@WindomZ
Last active April 19, 2017 09:08
Show Gist options
  • Save WindomZ/84e8d49b51666d6293632298c78a2407 to your computer and use it in GitHub Desktop.
Save WindomZ/84e8d49b51666d6293632298c78a2407 to your computer and use it in GitHub Desktop.
Usage: ./git-commit-modify-last-time.sh <seconds(like: 86400 = 60 * 60 * 24 (s) = 24 (h)>
#!/usr/bin/env bash
git stash && \
date=$(date -r $(expr $(date '+%s') + $1) +%s) && \
rm -rf "$(git rev-parse --git-dir)/refs/original/" && \
git filter-branch --env-filter \
"if [ \$GIT_COMMIT = \"$(git rev-parse HEAD)\" ]; then
export GIT_AUTHOR_DATE=\"$date\"
export GIT_COMMITTER_DATE=\"$date\"
export GIT_COMMITTER_NAME=\$GIT_AUTHOR_NAME
export GIT_COMMITTER_EMAIL=\$GIT_AUTHOR_EMAIL
fi" && \
git stash pop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment