Last active
June 30, 2020 14:44
-
-
Save potados99/ce629c34270f3bfd247ac46b8cc4608c to your computer and use it in GitHub Desktop.
Create a commit at N days before
This file contains 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
#!/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