7

我尝试在我的应用程序中提交一些更改,并收到一个错误,即开发日志在 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非快进被拒绝

4

2 回答 2

8

看来您之前已将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
于 2013-09-29T20:17:00.237 回答
4

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

  config.logger = Logger.new(STDOUT)

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

于 2013-09-29T20:20:41.583 回答