Skip to content

Instantly share code, notes, and snippets.

@petitchevalroux
Last active August 30, 2016 16:19
Show Gist options
  • Save petitchevalroux/d51f02ee2787b6b35be96911c8f5f4c8 to your computer and use it in GitHub Desktop.
Save petitchevalroux/d51f02ee2787b6b35be96911c8f5f4c8 to your computer and use it in GitHub Desktop.
Use this command instead of git commit to commit between two dates
#!/bin/bash
git commit "$@"
current=$(date +%s)
# Yesterday at 6pm UTC
start=$(($current - $current % 86400 - 3600 * 6))
# Yesterday at midnight UTC
end=$(($current - $current % 86400))
nextEnd=$(($end + 86399))
commitDate=$(( $start + $(bc -l <<< "$(($current - $end))/$(($nextEnd - $end))*$(($end - $start))" | awk '{print int($1+0.5)}')))
echo "$(date -r$start) < $(date -r$commitDate) < $(date -r$end)"
export GIT_COMMITTER_DATE=$commitDate; git commit --amend --date $commitDate --no-edit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment