揮発性のメモ2

http://d.hatena.ne.jp/iww/

gitのタイムスタンプをコミット時の時刻にする

本当はオリジナルのタイムスタンプを復元したいんだけど、それは失われるらしい


http://stackoverflow.com/questions/2179722/checking-out-old-file-with-original-create-modified-timestamps
このスクリプトが何用かわからなかったので、改造して使えるようにした

#!/bin/dash

for FILE in $(git ls-files); do
  TIME=$(git log --pretty=format:%ci -n1 $FILE)
  echo $TIME'\t'$FILE

  STAMP=$(date -d "$TIME" +"%y%m%d%H%M.%S")
  touch -t $STAMP $FILE
done
git ls-files ファイルの一覧を見る
git log --pretty=format:%ci
フォーマット指定%ciは日付を表示
-n1
1行だけ表示(新しいほう)

フォーマットは http://opensource.apple.com/source/Git/Git-19/src/git-htmldocs/pretty-formats.txt を見るといい