I receive the following error when pushing my commits
remote: warning: File var/log/system.log is 57.82 MB; this is larger than recommended maximum file size
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-repo
should 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.log
and var/report/752246136671
which exceed the limit, so I would suggest using filter-branch
for removing them for a git only solution:
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
, *.info
and other log files from the git repo completely by using a *.log
entry in your .gitignore
file. You can similarly ignore the var/reports
folder.
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
/joomla
installation to me, in that case ignore the var
folder completely in your .gitignore
, you don't want objects from var/cache
or var/session
etc to be tracked in the repo.
git rm
or git rm --cached
isn't enough to remove that file fir the history stored in your repo.
You need to:
use BFG Repo Cleaner, as suggested above.
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 -f
to force the new history on your remote repo.The message contains information about two files. var/log/system.log
generates a warning but it would be pushed. var/report/752246136671
is 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:
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:
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.