Skip to content

Instantly share code, notes, and snippets.

@gabrielfalcao
Created May 10, 2021 12:30
Show Gist options
  • Save gabrielfalcao/7ab7e38c004baea0c834335bd203ffad to your computer and use it in GitHub Desktop.
Save gabrielfalcao/7ab7e38c004baea0c834335bd203ffad to your computer and use it in GitHub Desktop.
#!/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