Created
May 10, 2021 12:30
-
-
Save gabrielfalcao/7ab7e38c004baea0c834335bd203ffad to your computer and use it in GitHub Desktop.
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 characters
#!/usr/bin/env bash | |
set -e | |
OLD_DATE="$(git show HEAD -q | grep Date | cut -d: -f2-)" | |
NEW_DATE="$(date)" | |
OLD_HASH=$(git show HEAD -q | head -1 | awk '{print $2}') | |
pretty() { | |
colorcode="${1}" | |
shift | |
string="${*}" | |
echo -en "\033[1;${colorcode}m${string}\033[0m" | |
} | |
echo "old date was: '$(pretty 31 $OLD_DATE)'" | |
echo "recreating commit with new date: '$(pretty 32 $NEW_DATE)'" | |
GIT_COMMITTER_DATE="${NEW_DATE}" git commit --amend -C HEAD --date "${NEW_DATE}" --author="Gabriel Falcão <[email protected]>" | |
NEW_HASH=$(git show HEAD -q | head -1 | awk '{print $2}') | |
echo "old hash was: $(pretty 31 $OLD_HASH)" | |
echo "new commit hash is: $(pretty 32 $NEW_HASH)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment