How to check that all git-lfs tracked and committed files are pointers?
Git LFS doesn't have a way to do this natively, although you could open an issue on the GitHub repository if you'd like to see support for it. In the mean time, you can implement this using a technique like the following:
git ls-files | git check-attr --stdin filter | \
awk -F': ' '$3 ~ /lfs/ { print $1}' | \
xargs -L1 sh -c 'git cat-file blob "HEAD:$0" | \
git lfs pointer --check --stdin || { echo "$0"; false; }'
If this command produces any output, then there is an invalid pointer file, and it should print which file it is. It will also exit zero if everything is okay, and nonzero if there's a broken file.
This does have the limitation that it doesn't handle file names with a colon-space or newline in them; if that matters, you'll have to use the -z
option and run things through perl
or ruby
instead of awk
.