Skip to content

Instantly share code, notes, and snippets.

@WindomZ
Last active April 19, 2017 09:05
Show Gist options
  • Save WindomZ/d2bd2f3b51f1ac335b0bf61e3a32878e to your computer and use it in GitHub Desktop.
Save WindomZ/d2bd2f3b51f1ac335b0bf61e3a32878e to your computer and use it in GitHub Desktop.
Usage: ./git-commit-modify-last-time.sh <date(like: Tue, 07 Feb 2017 07:00:00 +0800)>
#!/usr/bin/env bash
git stash && \
date=$(date -d "$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