You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多
文档控制台
免费开始使用

启用Git LFS后GitHub HTTPS推送失败:fatal: protocol error: bad line length报错求助

Fixing Git Push Protocol Error with Large LFS Files on Windows

Hey there, I’ve dealt with this exact "bad line length" and disconnect error when pushing large LFS-managed projects before—especially on Windows with HTTPS. Let’s walk through practical fixes tailored to your situation (new repo, 11GB+ project, LFS for files over 100MB):

1. Verify Git LFS Tracking Setup

First, make sure your large files are actually being tracked by LFS—this is a common oversight for new users:

  • Run git lfs ls-files to check if all your 100MB+ files show up in the list. If any are missing, use git lfs track "*.ext" (replace *.ext with your file type, like *.pak or *.assetbundle) to add them.
  • Don’t forget to commit the .gitattributes file that git lfs track creates—this tells Git which files to handle with LFS.
  • Reset your LFS installation to fix any misconfigurations:
    git lfs uninstall
    git lfs install
    

2. Increase Git HTTP Buffer Limits

Windows often hits issues with default HTTP buffer sizes when pushing large files. Tweak these settings:

  • Set a larger post buffer (150MB here, bigger than your largest file):
    git config --global http.postBuffer 157286400
    
  • Increase the max request buffer:
    git config --global http.maxRequestBuffer 100M
    
  • Disable HTTP compression (sometimes this causes connection drops with large payloads):
    git config --global http.compression 0
    

3. Push in Smaller Batches

Pushing 11GB of content all at once can overwhelm the connection. Try splitting the push:

  • First, push only small text files and configuration (like .gitattributes, source code) separately:
    git add .gitattributes
    git add <path-to-small-files>
    git commit -m "Initial commit: config and small files"
    git push origin master
    
  • Then push the LFS-managed large files separately:
    git lfs push origin master
    
  • If you’ve already committed everything, use git push origin master --no-verify to skip pre-push hooks that might be consuming resources.

4. Check Network & Proxy Settings

HTTPS connections on Windows can fail due to proxy or firewall restrictions:

  • If you’re using a proxy, either disable it temporarily for the push:
    git config --global --unset http.proxy
    git config --global --unset https.proxy
    
    Or ensure Git is configured to use your proxy correctly:
    git config --global http.proxy http://your-proxy:port
    git config --global https.proxy http://your-proxy:port
    
  • As a fallback, switch to SSH instead of HTTPS. Generate an SSH key, add it to your GitHub account, then update your remote URL:
    git remote set-url origin git@github.com:your-username/your-repo.git
    
    SSH is often more stable for large file transfers.

5. Clean Local LFS Cache & Resync

Corrupted local LFS objects can cause push failures:

  • Fetch all LFS objects to ensure your local copy is complete:
    git lfs fetch --all
    
  • Prune invalid or unused LFS objects:
    git lfs prune
    
  • If you have no uncommitted changes, reset your local repo to ensure consistency:
    git reset --hard origin/master
    
    (Warning: This will erase any local changes you haven’t committed—only do this if you’re sure!)

Give these steps a try in order—most users fix this with either adjusting the HTTP buffers or splitting the push. Let me know if you hit any snags!

内容的提问来源于stack exchange,提问作者visual coding

火山引擎 最新活动