【问题标题】:Development Log file exceeds GitHub's file size limit, even after deleting file开发日志文件超过了 GitHub 的文件大小限制,即使在删除文件之后也是如此
【发布时间】:2013-10-05 15:17:09
【问题描述】:

我尝试在我的应用程序中提交一些更改,并收到一个错误,即开发日志在 512MB 时太大。我删除了开发日志文件并再次尝试,同样的错误出现了,日志大小为 103.2MB。我也尝试了rake log:clear,但出现了同样的错误。

显然开发日志文件正在被重写。我从来没有使用过日志,可能不会错过它们......有没有办法提交到 git 而不会重写开发日志?

 2 files changed, 0 insertions(+), 1096498 deletions(-)
 rewrite log/development.log (100%)
 rewrite log/production.log (100%)
[master]~/Projects/schoolsapi: git push origin master
Username: 
Password: 
Counting objects: 26, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (15/15), done.
Writing objects: 100% (17/17), 6.90 MiB | 322 KiB/s, done.
Total 17 (delta 7), reused 0 (delta 0)
remote: Error code: 026c4e06d174bf5b0e51c754dc9459b0
remote: warning: Error GH413: Large files detected.
remote: warning: See http://git.io/iEPt8g for more information.
remote: error: File log/development.log is 103.32 MB; this exceeds GitHub's file size limit of 100 MB

在尝试以下答案 1 和 2 的建议后更新:

问题依然存在。我已经从 git repo 中删除了日志文件,并且我的本地机器插入了 .gitignore 文件并使用配置记录器位更新了 development.rb。下面的最后两行表明 git 或我的本地机器中不存在 development.log 文件。

master]~/Projects/schoolsapi: git add .
[master]~/Projects/schoolsapi: git commit -m"Tried config logger per apnea diving"
[master b83b259] Tried config logger per apnea diving
 2 files changed, 4 insertions(+), 0 deletions(-)
 create mode 100644 .gitignore
[master]~/Projects/schoolsapi: git push origin master
Username: 
Password: 
Counting objects: 38, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (23/23), done.
Writing objects: 100% (26/26), 6.90 MiB | 525 KiB/s, done.
Total 26 (delta 12), reused 0 (delta 0)
remote: Error code: e69d138ee720f7bcb8112e0e7ec03470
remote: warning: Error GH413: Large files detected.
remote: warning: See http://git.io/iEPt8g for more information.
remote: error: File log/development.log is 103.32 MB; this exceeds GitHub's file size limit of 100 MB
[master]~/Projects/schoolsapi: rm log/development.log
rm: log/development.log: No such file or directory
[master]~/Projects/schoolsapi: git rm log/development.log
fatal: pathspec 'log/development.log' did not match any files
[master]~/Projects/schoolsapi: 

更新

我之前的提交仍然有 log/development.log 文件。使用下面所选答案提供的此代码(非常感谢此人),问题已通过一个小警告得到解决:

git filter-branch --index-filter 'git rm --cached --ignore-unmatch log/development.log' --tag-name-filter cat -- --all

需要注意的是,我必须使用 git push origin +master 来覆盖 git 对非快进更新的自动拒绝。我这样做很舒服,因为我是唯一一个在这个应用程序上工作的人。看到这个问题:

Git non-fast-forward rejected

【问题讨论】:

    标签: ruby-on-rails git logging


    【解决方案1】:

    看来您之前已将 development.log 文件添加/签入到 git 存储库中。

    你需要删除它,然后提交。

    git rm log/development.log
    git commit -m "removed log file"
    

    一般来说,你应该把你的日志目录放到你的 .gitignore 文件中

    echo log >> .gitignore
    

    并完全删除所有日志文件(以防添加其他日志文件)

    git rm -r --cached log
    git commit -m "removed log file"
    

    Github 最近开始对最大文件大小实施 100MB 的限制。 https://help.github.com/articles/working-with-large-files

    编辑:

    您之前的提交似乎没有在本地推送到 github。

    尝试运行

    git filter-branch --index-filter 'git rm --cached --ignore-unmatch log/development.log' --tag-name-filter cat -- --all
    

    【讨论】:

    【解决方案2】:

    防止文件在您自己的磁盘上扩展的侧面答案,只需在development.rb 中登录到STDOUT

      config.logger = Logger.new(STDOUT)
    

    您将在服务器页面上保留日志,但不会再填充该文件。

    【讨论】:

    • 感谢您的建议,非常感谢。
    • 我在启动 rails 服务器时遇到了 问题,它没有将日志打印到标准输出。将该行放入 .rb 有帮助。谢谢。但是日志在日志文件和标准输出中。我不介意,但想指出。使用导轨 5
    猜你喜欢
    • 1970-01-01
    • 2015-09-29
    • 2012-07-22
    • 2010-12-08
    • 1970-01-01
    • 1970-01-01
    • 2018-09-24
    • 1970-01-01
    • 2011-11-03
    相关资源
    最近更新 更多