Created
June 3, 2019 18:32
-
-
Save dceoy/eae40cf0b365fbae4f19fe89b74bd995 to your computer and use it in GitHub Desktop.
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