使用git push到github时有大文件的错误
2015-07-06 09:18
639 查看
出处:http://stackoverflow.com/questions/22227851/error-while-pushing-to-github-repo/22228417
比较建议使用第二种答案
activeoldestvotes
比较建议使用第二种答案
Error
while pushing to github repo
up vote2down votefavorite 2 | I receive the following error when pushing my commits[code]remote: warning: File var/log/system.log is 57.82 MB; this is larger than recommended maximum file size of 50 MB remote: error: GH001: Large files detected. remote: error: Trace: 96d01231dffac3fbc3ba1eb2e9f01a93 remote: error: See http://git.io/iEPt8g for more information. remote: error: File var/report/752246136671 is 100.86 MB; this exceeds github's file size limit of 100 MB I tried the following the commands listed step by step below: [code]git push -u origin master cant find these in git files to commit when i typed git status. Could you please let me know how to push my changes to repo without these errors ? I guess these files are in github index . I also tried git rm --cached var/log/system.log. but no results. hitting my head to wall ! UPDATE 1 Kindly find the Gists here based on the two answers from experts below: answer#1 - https://gist.github.com/haijerome/9405598 answer#2 -https://gist.github.com/haijerome/9405492 UPDATE 2 Kindly find below the git Log details for the both the files that i tried to remove: https://gist.github.com/haijerome/9406273 https://gist.github.com/haijerome/9406263 ANSWER THAT WORKED Please find the gist for the final answer that solved my issue https://gist.github.com/haijerome/9478989 credits to git experts VonC, Holger Just and all other experts who have provided their inputs and ofcourse to stackoverflow. git github
| |||
add a comment |
4 Answers
activeoldestvotesup vote4down voteaccepted +50 | git rmor git rm --cachedisn't enough to remove that file fir the history stored in your repo. You need to: use BFG Repo Cleaner, as suggested above. [code]bfg --strip-blobs-bigger-than 1M my-repo.git use git gc --agrressive --prune=now(after BFG), as detailed in "Reduce git repository size" git push -fto force the new history on your remote repo.
| ||||||||||||
a comment |
up vote1down vote | The message contains information about two files. var/log/system.loggenerates a warning but it would be pushed. var/report/752246136671is too large and thus prevents the push. You thus have to delete at least the latter file. Before Github will let you push, you'll have to remove the file from all commits you want to push. It is not enough to just delete the file in a later commit after having it added before. According to the article linked in the message, you can perform one of the two recommended operations: If you have added the file in the most recent commit, you can change it to remove the file: [code]git rm --cached var/report/752246136671 # 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 you can use The BFG to filter your repository and remove the file from all commits. This is required if you have added the file in the git history (as opposed to only in your most recent commit), you have to clean your history. Github will not allow to push the large file in any commit even if it is later removed again. This is because in this case, the file will still be part of the history and will thus bloat the repo. You can install The BFG from https://github.com/rtyley/bfg-repo-cleaner/releases/latest. The you can remove any indication of any files larger than 100MB by running this command: [code]cd /path/to/your/git/repo java -jar bfg.jar --strip-blobs-bigger-than 100M # Git history will be cleaned - files in your latest commit will *not* be touched Note that this will change history of your repository, leading to a potential force-push. You might thus have to coordinate with your fellow developers. Also, if you still need the file, you should make a backup before as you won't be able to restore it from git.
| ||||||||||||||||
a comment |
up vote1down vote | The problem at hand is that while you have removed the relevant files using new commits, there are blobs corresponding to the older commits for the same files in you repo, and the size of 2 of these objects is throwing you a warning and an error. To be able to push again, you need to remove the same as well. While bfg-reposhould work for most people to rectify the situation here, it requires java to be installed and configured on the system and that is not always available. You have 2 files var/log/system.logand var/report/752246136671which exceed the limit, so I would suggest using filter-branchfor removing them for a git only solution: [code]git filter-branch --index-filter 'git rm --cached --ignore-unmatch var/log/system.log var/report/752246136671' --tag-name-filter cat -- --all You might need to force push the changes later (using git push -f origin). In general, it is a good practice to ignore the *.log, *.infoand other log files from the git repo completely by using a *.logentry in your .gitignorefile. You can similarly ignore the var/reportsfolder. In case there are files which have already been committed to the repo and pushed earlier, you might need to use git rm --cached "*.log"to remove the same and commit those changes to untrack them permanently. PS: This seems like a magento/ joomlainstallation to me, in that case ignore the varfolder completely in your .gitignore, you don't want objects from var/cacheor var/sessionetc to be tracked in the repo.
| ||||
a comment |
up vote0down vote | It's clear that you are trying to push a very big file, as the error is indicating. It is also a log file, therefore I assume it should not be in the repository. If this is true, do this to fix the error: [code]$ git rm var/log/system.log $ git commit -m "Delete system.log file" $ git push -u origin master
| ||||||||
|
相关文章推荐
- 黑马程序员——C语言之选择排序、折半查找法与二维数组
- 【Spring】AOP - 面向切面
- 【Zendstudio】如何利用zendstudio新建 或导入php项目
- C++ Virtual详解
- python创建临时文件夹的方法
- Ubuntu下安装PHP Mcrypt扩展
- C#编写简单的聊天程序
- C#编写简单的聊天程序
- 最常用的两种C++序列化方案的使用心得(protobuf和boost serialization)
- javaee jsp中servlet发生java.lang.ClassNotFoundException可能原因
- thinkphp验证码在服务器显示不了
- Qt写入txt文件
- Java数组List换算方法
- Eclipse快速打开当前文件所在文件夹
- 八大排序算法的C++实现
- C++类型转换关键字 *_cast<type> (expression)
- 从eclipse中导入myeclipse项目运行是出现“不能部署到服务器”的错误。
- C++类的所占空间
- 解决Ruby在IE11中报Unable to get browser (Selenium::WebDriver::Error::NoSuchWindowError)的错误
- C#设计模式(4)——抽象工厂模式(Abstract Factory)