Skip to content

Instantly share code, notes, and snippets.

@SOF3
Last active April 28, 2021 07:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SOF3/c690550f6883b5322aa4cdbce3a6112a to your computer and use it in GitHub Desktop.
Save SOF3/c690550f6883b5322aa4cdbce3a6112a to your computer and use it in GitHub Desktop.
Update the mtime of all files in a git repository to the last commit time instead of checkout time
#!/usr/bin/env sh
# Update the mtime of all files in a git repository to the last commit time instead of checkout time
git ls-files | \
while read file; do
date="$(git log -1 --format="%cD" "$file")"
touch -d"$data" "$file"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment