Skip to content

Instantly share code, notes, and snippets.

@morganp
Created September 4, 2016 17:38
Show Gist options
  • Save morganp/c80f88f52cd1639b6a426a89c27b76fc to your computer and use it in GitHub Desktop.
Save morganp/c80f88f52cd1639b6a426a89c27b76fc to your computer and use it in GitHub Desktop.
Change date on git commits
#!/bin/bash
# commit
# date YYYY-mm-dd HH:MM:SS
# http://stackoverflow.com/a/24584976/97073
# git cdc @~ "2014-07-04 20:32:45"
#Reset commit before HEAD
#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")
#
#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"
custom_date_value="Thu Nov 14 20:30:24 2013 +0000"
GIT_COMMITTER_DATE=$custom_date_value
git commit --amend --date="$custom_date_value"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment