git-set-mtimes 327 B

123456789101112
  1. #!/bin/bash
  2. set -e
  3. IFS=$'\n'
  4. files=( $({ git ls-files | xargs -n1 dirname | sort -u && git ls-files; } | sort -r) )
  5. unset IFS
  6. for f in "${files[@]}"; do
  7. stamp="$(git --no-pager log -1 --format='format:%ai' -- "$f")"
  8. touchFormat="$(date --date="$stamp" +'%Y%m%d%H%M.%S')"
  9. touch --no-dereference -t "$touchFormat" "$f"
  10. done