10

I have a git repository with git-lfs installed and I would like to have all PDF files above some size in LFS, but not all PDF files, as git-lfs supports. The reason for this is that I have many tiny PDF figure files in vector format which are ok to have in regular version control, and a few large PDFs.

Is it possible to configure git-lfs this way?

I use git from Atlassian source-tree and host the repository in bitbucket, maybe those support this more advanced use-case?

Uri Cohen
  • 3,488
  • 1
  • 29
  • 46

1 Answers1

3

Unfortunately, this is not possible on git-lfs. See issue #282.

There is however a hack provided by user Baccanno, but I wouldn't recommend it for repositories with many files. It tracks all files above a threshold, but it could be modified to do it for PDF's only.

The hack:

(Copied here without warranty)

Put this in the [alias] section of your git config (project_root/.git/config) and change the 300k at the end to the size you wish

track-large = !"git st --porcelain --ignore-submodules | grep -v \"D \" | awk '{ l=length($0); s=substr($0,4,l-1); print s}' | sed -n 's/\\(\\(.* -> *\\)\\|\\)\\(.*\\)/\\3/p' | xargs -I{} find {} -size +300k | xargs -I{} git lfs track \"{}\""
abrac
  • 521
  • 5
  • 12