Last active
November 11, 2016 17:04
-
-
Save jswrenn/a26f421eb3f548a679872d8969395393 to your computer and use it in GitHub Desktop.
Commit each file in the current working directory using its time of last modification.
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
git ls-files -z --others --exclude-standard \ | |
| xargs -0 -I{} stat -c "%Y %n" "{}" \ | |
| sort \ | |
| cut -d' ' -f 2- \ | |
| while read -r name; do | |
DATE=$(stat -c "%y" "$name") | |
git add "$name" | |
export GIT_AUTHOR_DATE="$DATE" | |
export GIT_COMMITTER_DATE="$DATE" | |
git commit -m "$name"; | |
done | |
git ls-files -z --modified --exclude-standard \ | |
| xargs -0 -I{} stat -c "%Y %n" "{}" \ | |
| sort \ | |
| cut -d' ' -f 2- \ | |
| while read -r name; do | |
DATE=$(stat -c "%y" "$name") | |
git add "$name" | |
export GIT_AUTHOR_DATE="$DATE" | |
export GIT_COMMITTER_DATE="$DATE" | |
git commit -m "Updated $name"; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment