简体   繁体   English

如何忽略大文件并推送到git repo

[英]How can I ignore big files and push to git repo

Before, I used git locally without using .gitignore Afterwards, I created an .gitignore file, and write all unnecessary files in it. 之前,我在本地使用git而不使用.gitignore然后,我创建了一个.gitignore文件,并在其中写入所有不必要的文件。 When I push them to git repo, fatal: The remote end hung up unexpectedly error appears. 当我把它们推到git repo时,致命:远程端挂断意外错误出现。

I dont want to push ignore files, but, somehow git tries to push them to repo. 我不想推送忽略文件,但是,不知何故,git试图将它们推送到repo。

Please help me, what is my fault? 请帮帮我,我的错是什么? Thanks 谢谢

GitHub has a nice article on this . GitHub有一篇很好的文章 You basically want to remove the files from Git history, but not from the file system. 您基本上想要从Git历史记录中删除文件,但不是从文件系统中删除。

  • 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 -a工具清理存储库( 替代git-filter-branch ):

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

    This will remove files bigger than 50M. 这将删除大于50M的文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM