Git error, need to remove large file

前端 未结 8 576
北恋
北恋 2021-02-01 05:37

I am getting this error when I try to push to git and I have no idea how to fix it.

Counting objects: 1239, done.
Delta compression using up to 4 threads.
Compre         


        
相关标签:
8条回答
  • 2021-02-01 06:06

    To remove large files, GitHub suggests:

    $ git rm --cached giant_file
    # Stage our giant file for removal, but leave it on disk
    
    git commit --amend -CHEAD
    # Amend the previous commit with your change
    # Simply making a new commit won't work, as you need
    # to remove the file from the unpushed history as well
    
    git push
    # Push our rewritten, smaller commit
    

    Or if you want more general information on how to work with large files on GitHub.

    And next time add /log in your .gitignore

    0 讨论(0)
  • 2021-02-01 06:10

    To improve upon one of the reply above, you need

    git filter-branch -f --tree-filter 'rm -f /path/to/file' HEAD --all
    

    in order to remove your file even from the history. You need -f to force rewriting any backup and --all to remove file from all branches. More information here: Git docs

    Your large file error won't go away by removing it from the git cache because it is still lurking in the commit history.

    0 讨论(0)
提交回复
热议问题