User
User

Reputation: 24741

Large file stuck in git commit

remote: error: GH001: Large files detected. You may want to try Git Large File Storage

I deleted the file. Below, you can see me trying to push, then trying to remove the file from the cache.

enter image description here

How do I get rid of this large file so I can push again?

Upvotes: 1

Views: 3971

Answers (3)

Mahmoud Abdelsattar
Mahmoud Abdelsattar

Reputation: 1441

One good solution that worked for me:

git filter-branch --tree-filter 'rm path/to/your/bigfile' HEAD

and then:

git push origin master --force

Upvotes: 0

Schwern
Schwern

Reputation: 164919

The file must not just be deleted, it must be removed from history. This is the same procedure you'd follow to remote a sensitive file, such as a password file.

There's a number of ways to do this, the simplest is to follow the instructions on Github. They show two ways to scrub the file from all commits it is present in.

Upvotes: 2

User
User

Reputation: 24741

I ended up doing a work around.

  1. Backup all my files to another folder: cp . ../backup
  2. Remove .git from the backup: rm -R ..backup/.git
  3. Find the latest good commit on the server and restore to it: git reset --hard c14809fa
  4. Copy all old files back: cp ../backup .

Then just go ahead and commit and push.

Upvotes: 4

Related Questions