Trey
Trey

Reputation: 394

Find and remove too large of files to push in git lfs

I have a commit, and I am trying to push it. I get this response

Git LFS: (0 of 9 files, 9 skipped) 0 B / 3.24 GB, 3.24 GB skipped
[422] Size must be less than 2147483648
[0ee4f2bc4d42d98ea0e7b5aeba2762c7482f3bcf00739d40b922babe8061820b] Size must be less than 2147483648
error: failed to push some refs to ...

What files are these?

How can I find and remove them from my commit so I can push all these files up?

Upvotes: 9

Views: 6592

Answers (2)

Ben Thomas
Ben Thomas

Reputation: 1498

On macOS, I had to use a different command than what @MarcusMüller suggested, because the stat command is slightly different:

  1. -f instead of -c
  2. %z instead of %s
  3. %N instead of %n

So the command is as follows:

git ls-files -z | xargs -0 stat -f '%z %n' | sort -n

Upvotes: 0

Marcus Müller
Marcus Müller

Reputation: 36482

A simple

git ls-files

will give you a listing of files currently managed by git.

With a bit of pipe magic, the file over size limit get's pretty easy to spot

git ls-files -z | xargs -0 stat -c '%s %n' | sort -n 

will give you an ascendingly sorted list of file sizes and corresponding files.

Upvotes: 16

Related Questions