Last active
November 3, 2016 16:00
-
-
Save demofly/acf236b9e7ba4cc82fd89e7489147142 to your computer and use it in GitHub Desktop.
How to recover mtime dates from git log: recover-mtime-dates-from-git.sh
This file contains hidden or 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/bash | |
git ls-tree `git rev-parse HEAD` -rt --full-tree | sed -r 's#\w+ \w+ \w+\s+##' | while read FILE | |
do | |
TIME=$(git log --pretty=format:%cd -n 1 --date=iso "$FILE" 2>/dev/null) | |
test -z "$TIME" && continue | |
# TIME2=`echo $TIME | sed 's/-//g;s/ //;s/://;s/:/\./;s/ .*//'` | |
echo "$FILE" | |
# echo -n " - old mtime: " | |
# date -r "$FILE" -Ins | |
# echo " - new mtime: $TIME2" | |
## When you want to recover back the timestamps: | |
touch -h -m -d "$TIME" "$FILE" | |
# touch -h -m -t $TIME2 "$FILE" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment