Created
June 3, 2019 18:32
Revisions
-
Daichi Narushima created this gist
Jun 3, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ #!/usr/bin/env bash # # Usage: ./git_rewind_days.sh <int> set -eux DAYS_TO_REWIND="${1}" COMMIT_DATE=$(git log -1 | sed -ne 's/^Date: \+//p') REWIDED_DATE=$(date -d "${COMMIT_DATE% *} - ${DAYS_TO_REWIND} days" | awk '{print $1" "$2" "$3" "$4" "$6}')" ${COMMIT_DATE##* }" git rebase HEAD^ git commit --amend --no-edit --date "${REWIDED_DATE}" git rebase HEAD^ --committer-date-is-author-date