Created
February 12, 2015 16:52
-
-
Save tstone2077/86529356dd120eb0e51f to your computer and use it in GitHub Desktop.
Script to set the times of a working copy to the last commit time.
This file contains 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 | |
# Usage: git settimes [-v] | |
SAVE_IFS=$IFS | |
VERBOSE="False" | |
if [[ $1 == "-v" ]]; then | |
VERBOSE="True" | |
fi | |
IFS=$(echo -en "\n\b") | |
for FILE in $(git ls-files) | |
do | |
if [[ $VERBOSE == "True" ]]; then | |
echo Updating timestamp: $FILE | |
fi | |
TIME=$(git log --pretty=format:%cd -n 1 --date=iso -- "$FILE") | |
#TIME=$(date -f '%Y-%m-%d %H:%M:%S %z' "$TIME" +%Y%m%d%H%M.%S) | |
TIME=$(date -d "$TIME" +%Y%m%d%H%M.%S) | |
touch -m -t $TIME "$FILE" | |
done | |
IFS=$SAVE_IFS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment