Created
February 12, 2026 16:24
-
-
Save EkriirkE/1fb96c2f8d144e205682338d3f187fed to your computer and use it in GitHub Desktop.
Preserve file ownership and timestamps of entire working folder with git commits
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
| #EkriirkE stats | |
| IGNORE=("." ".stats") | |
| if [ -f .statsignore ]; then | |
| while read -r l; do | |
| [[ ! -z "$l" ]] && IGNORE+=("$l") | |
| done < .statsignore | |
| fi | |
| if [ -f .gitignore ]; then | |
| while read -r l; do | |
| [[ ! -z "$l" ]] && IGNORE+=("$l") | |
| done < .gitignore | |
| fi | |
| ARGS=() | |
| for i in "${IGNORE[@]}"; do | |
| if [[ "$i" =~ "/" ]]; then | |
| ARGS+=(-not -path "./$i") | |
| else | |
| ARGS+=(-not -name "$i") | |
| fi | |
| done | |
| echo "#EkriirkE stats" >.stats | |
| find -not -path "*/.git*" "${ARGS[@]}" -printf 'F="%p"\n' -printf 'chown -h %U:%G "$F"\n' \( \! -type l -printf 'chmod %#m "$F"\n' \) -printf 'touch -hcmd "%TY-%Tm-%Td %TH:%TM:%TS %TZ" "$F"\n' >>.stats | |
| echo 'touch -r $(ls -t | head -1) ".stats"'>>.stats | |
| touch -r $(ls -t | head -1) ".stats" | |
| git add .stats |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
v2 based on actual commits, not whole working directory