我如何忽略大文件并推送到git repo [英] How can I ignore big files and push to git repo

查看:209
本文介绍了我如何忽略大文件并推送到git repo的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

之前,我在本地使用git而不使用 .gitignore
之后,
我创建了一个 .gitignore 文件,并在其中写入所有不必要的文件。
当我把它们推到git repo时,致命的:远端意外挂起错误出现。



我不想推忽略文件,但不知何故git试图推动他们回购。



请帮助我,我的过错是什么?谢谢

解决方案

GitHub有一个的不错文章。您基本上想要从Git历史记录中删除文件,但不是从文件系统中删除文件。


  • 如果您的文件被推入最后一次提交,你可以这样做:

      git rm --cached path / to / your / big / file 
    git commit --amend -CHEAD
    git push


  • 如果不是,他们推荐使用 BFG - 一种工具清理仓库(替代git-filter-branch ):

      bfg --strip-blobs -bigger-than 50M 

    这将删除大于50M的文件。



Before, I used git locally without using .gitignore Afterwards, I created an .gitignore file, and write all unnecessary files in it. When I push them to git repo, fatal: The remote end hung up unexpectedly error appears.

I dont want to push ignore files, but, somehow git tries to push them to repo.

Please help me, what is my fault? Thanks

解决方案

GitHub has a nice article on this. You basically want to remove the files from Git history, but not from the file system.

  • If your file was pushed in your last commit, you can do:

    git rm --cached path/to/your/big/file
    git commit --amend -CHEAD
    git push
    

  • If not, they recommend using BFG–a tool for cleaning up repositories (alternative to git-filter-branch):

    bfg --strip-blobs-bigger-than 50M
    

    This will remove files bigger than 50M.

这篇关于我如何忽略大文件并推送到git repo的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆