Skip to content

Instantly share code, notes, and snippets.

@potados99
Last active June 30, 2020 14:44
Show Gist options
  • Save potados99/ce629c34270f3bfd247ac46b8cc4608c to your computer and use it in GitHub Desktop.
Save potados99/ce629c34270f3bfd247ac46b8cc4608c to your computer and use it in GitHub Desktop.
Create a commit at N days before
#!/bin/zsh
# Commit N days before
# At least one arg needed.
if [ $# -lt 1 ]; then
echo "Usage: ./commit-n-days-before [N]"
exit 1
fi
N=$1
# N must be a number.
if [ -n $N ] && [ $N -eq $N ] 2>/dev/null; then
# OK. It is a number.
else
echo "N must be a number."
exit 1
fi
shift
N_DAYS_BEFORE=$(date -v -"$N"d +%Y-%m-%dT%H:%M:%S)
# Must be in a single line.
GIT_AUTHOR_DATE=$N_DAYS_BEFORE GIT_COMMITTER_DATE=$N_DAYS_BEFORE git commit $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment