9

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?

Marcus Müller
  • 34,677
  • 4
  • 53
  • 94
Trey
  • 394
  • 1
  • 4
  • 17
  • One way would be to call `git status` and if these are few files check them one to one. Other suggestion based on filesystem tools like find with a size option ... your choice. HTH – Dilettant Jun 01 '16 at 18:56

1 Answers1

15

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.

Marcus Müller
  • 34,677
  • 4
  • 53
  • 94
  • The list seems to work nice. I saw the two largest files looked like this `419024639 backups/14_12_2015.zip 2921741563 backups/18_04_2016.zip ` I then ran `git reset HEAD^ backups/18_04_2016.zip` and `git reset HEAD^ backups/14_12_2015.zip` then `git commit -c ORIG_HEAD` then `git push origin master -f` . I still get the same error. Do you know what Im doing wrong? – Trey Jun 01 '16 at 19:33
  • I don't know the default push behaviour in this particular case. Possibly, you're still pushing history containing the full in size – Marcus Müller Jun 01 '16 at 19:50
  • I needed to use `git reset --soft HEAD~2` to get it to work for me – Trey Jun 01 '16 at 22:04
  • This command does not work for me. Is it for Linux only? I'm on Windows... – Alexis.Rolland Feb 07 '20 at 04:18
  • 2
    @Alexis.Rolland no, that's got nothing to do with the OS you're on. It might depend on the shell and environment you're using – on Linux systems, you'd typically find `xargs` and `sort` already installed, on Windows you'd usually install it with a shell you use for git. Windows is always a bit underequipped when it comes to tooling. – Marcus Müller Feb 07 '20 at 09:19
  • In git bash on Windows, I get `stat: missing operand` when using the command `git ls-files -z | xargs -0 stat -c '%s %n' | sort -n ` – Pro Q Nov 06 '20 at 03:42
  • that means there's no files that `git ls-files` reports. Wrong directory? – Marcus Müller Nov 06 '20 at 08:33
  • @softwareisfun *which* xargs on windows? There's dozens of ways of getting an `xargs` executable that runs on windows... – Marcus Müller Aug 24 '21 at 17:16
  • `git ls-files -z | xargs -0 stat -c '%s %n' | numfmt --to=iec | sort -h` for human-readable sizes. – Martin Valgur Aug 15 '22 at 11:05