Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

My git push is stuck on a large file. What to do?

Tags:

git

I get a fatal sha1 error. I believe it is stuck trying to write large files. My status says I'm 8 commits ahead. I've tried to add the file extension to an ignore list in the exclude folder but it is still stuck. How do I proceed without losing my local changes (other than the large files)?

I've tried Predict how much data will be pushed in a git push and the bundle is huge ~650MB.

I don't know how to ignore the files from previous commits that were not pushed. Can I clear the old commits without losing the local files? Then delete the large files then commit again?

like image 280
dsbmac Avatar asked May 11 '14 05:05

dsbmac


1 Answers

From http://git-scm.com/book/en/Git-Tools-Rewriting-History :

Removing a File from Every Commit

This occurs fairly commonly. Someone accidentally commits a huge binary file with a thoughtless git add ., and you want to remove it everywhere. Perhaps you accidentally committed a file that contained a password, and you want to make your project open source. filter-branch is the tool you probably want to use to scrub your entire history. To remove a file named passwords.txt from your entire history, you can use the --tree-filter option to filter-branch:

$ git filter-branch --tree-filter 'rm -f passwords.txt' HEAD

But if it's only last commit you messed up you can solve it with git rm large_file and git commit --amend

like image 174
kaman Avatar answered Oct 16 '22 08:10

kaman