fixGitTimestamps.sh 426 B

123456789101112131415
  1. #! /bin/bash
  2. # Fix timestamps on tig files per ls-files
  3. #
  4. # Original from http://stackoverflow.com/questions/2179722/checking-out-old-file-with-original-create-modified-timestamps/30143117#30143117
  5. #
  6. # Fixed to work with ubuntu.
  7. for FILE in $(git ls-files)
  8. do
  9. TIME=$(git log --pretty=format:%cd -n 1 --date=iso $FILE)
  10. TIME2=`echo $TIME | sed 's/-//g;s/ //;s/://;s/:/\./;s/ .*//'`
  11. touch -m -t $TIME2 $FILE
  12. done