Skip to content

Instantly share code, notes, and snippets.

@drewler
Last active July 24, 2017 16:37
Show Gist options
  • Save drewler/7a9da156ce807e14b1fd977acb222b56 to your computer and use it in GitHub Desktop.
Save drewler/7a9da156ce807e14b1fd977acb222b56 to your computer and use it in GitHub Desktop.
Shell function used to force a date when creating a git commit
# The date format can be any valid input string for GNU date tool
# GNU date examples: https://www.gnu.org/software/coreutils/manual/html_node/Examples-of-date.html
# Some usage examples:
# git-commit-date "now +3 hour" --all
# git-commit-date "2 days ago"
# git-commit-date "1933-01-16 22:32:44" -m "Where were you on the night of January the 16th?"
function git-commit-date(){
export GIT_AUTHOR_DATE=`date -d"$1" --rfc-email`
export GIT_COMMITTER_DATE=$GIT_AUTHOR_DATE
shift
git commit $@
unset GIT_AUTHOR_DATE
unset GIT_COMMITTER_DATE
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment