Skip to content

Instantly share code, notes, and snippets.

@pixelpicosean
Created May 15, 2016 23:54
Show Gist options
  • Select an option

  • Save pixelpicosean/15bc2f414776ff11112e4f481717a450 to your computer and use it in GitHub Desktop.

Select an option

Save pixelpicosean/15bc2f414776ff11112e4f481717a450 to your computer and use it in GitHub Desktop.
#!/bin/bash
# commit
# date YYYY-mm-dd HH:MM:SS
commit="$1" datecal="$2"
temp_branch="temp-rebasing-branch"
current_branch="$(git rev-parse --abbrev-ref HEAD)"
date_timestamp=$(gdate -d "$datecal" +%s)
date_r=$(gdate -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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment