启用Git LFS后GitHub HTTPS推送失败:fatal: protocol error: bad line length报错求助
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-filesto check if all your 100MB+ files show up in the list. If any are missing, usegit lfs track "*.ext"(replace*.extwith your file type, like*.pakor*.assetbundle) to add them. - Don’t forget to commit the
.gitattributesfile thatgit lfs trackcreates—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-verifyto 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:
Or ensure Git is configured to use your proxy correctly:git config --global --unset http.proxy git config --global --unset https.proxygit 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:
SSH is often more stable for large file transfers.git remote set-url origin git@github.com:your-username/your-repo.git
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:
(Warning: This will erase any local changes you haven’t committed—only do this if you’re sure!)git reset --hard origin/master
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




