Search code examples
linuxfind

Look for big files not in the .git directory


I am tracking some big files with git annex. I usually do:

find . -type f -size +10M | xargs -r git annex add

The problem is that find encounters the big files in the .git directory:

find . -type f -size +10M

Output:

./.git/annex/objects/47/fx/SHA256E-s1208418304--5bca6a4c23b7c92976076e1a2490e81a6181301c86d2c2737840bb5b50a285d1.vmdk/SHA256E-s1208418304--5bca6a4c23b7c92976076e1a2490e81a6181301c86d2c2737840bb5b50a285d1.vmdk
./.git/annex/objects/ZZ/Q5/SHA256E-s3262054400--63bc227c3247ed9dfcb41d5ed20b887cf0ba2ef207dfae0ba95160efcbc89581.vmdk/SHA256E-s3262054400--63bc227c3247ed9dfcb41d5ed20b887cf0ba2ef207dfae0ba95160efcbc89581.vmdk
./.git/annex/objects/zj/mK/SHA256E-s6072303616--efdb32d49d31557a84f66fdb9871e24b63aa97b19956f050e2516cf392cd2467.vdi/SHA256E-s6072303616--efdb32d49d31557a84f66fdb9871e24b63aa97b19956f050e2516cf392cd2467.vdi

And git annex tries to readd them.

How can I tell 'find' to ignore (prune) the files in the .git directory, while still filtering for big files (+10M)? I am unable to construct the right command.


Solution

  • Remove .git/ from the descent candidate list.

    find . -name .git -type d -prune -o -type f -size +10M -print0 | xargs -0 ...