The following is the GNU All-permissive License as recommended in https://www.gnu.org/licenses/license-recommendations.en.html

Copyright (C) 2024 Free Software Foundation sysadmin@fsf.org

Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. This file is offered as-is, without any warranty.

Contributions are welcome. See https://savannah.gnu.org/maintenance/fsf/.

git corrupted files

Run this in the git repo to check the git objects in a bare repo, or in .git of a normal repo:

git fsck

The above command doesn't always correct checked out files in a regular repo, so the cache must be cleared. (Uncommited changes will be lost!)

git rm -r --cached .
git reset --hard

If you want to automate that command on a directory containing many git subdirectories:

ls */.git -d | sed -e "s:/.git$::" | sort > repos-in-this-dir

while read line ; do echo NEXT $line ; cd $line ; git rm -r --cached . ; git reset --hard ; cd .. ; done < repos-in-this-dir 2>&1 | less