Git LFS结合GitHub SSH推送失败,大文件未被追踪求助
Git LFS推送GitHub失败:大文件未被追踪+SSH连接异常
环境版本
> git version git version 2.39.3 (Apple Git-145) > git lfs version git-lfs/3.6.1 (GitHub; darwin arm64; go 1.23.4)
操作流程及问题
新建无提交记录的仓库后,按以下步骤操作:
> git init > git lfs track "*.db" > cat .gitattributes *.db filter=lfs diff=lfs merge=lfs -text > git add .gitattributes > git commit -m "init" ... > git add mybigfile.db > git lfs status On branch main Objects to be committed: mybigfile.db (Git: 09539d3) Objects not staged for commit: > git commit -m "add .db" ... > git lfs ls-files (无输出) > git remote add origin git@github.com:username/myrepo.git > git push -u origin main
推送时触发大文件超限错误:
remote: error: Trace: 8f76... remote: error: File mybigfile.db is 157.89 MB; this exceeds GitHub's file size limit of 100.00 MB remote: error: GH001: Large files detected. You may want to try Git Large File Storage. To github.com:username/myrepo.git ! [remote rejected] main -> main (pre-receive hook declined) error: failed to push some refs to 'github.com:username/myrepo.git'
已尝试的操作
开启调试日志执行推送:
GIT_TRACE=1 git push (或 GIT_CURL_VERBOSE=1);
得到错误日志:
20:43:44.031634 trace git-lfs: pure SSH connection unsuccessful (#0) 20:43:44.031676 trace git-lfs: pure SSH protocol connection failed (upload, origin): Unable to negotiate version with remote side (unable to read capabilities): EOF Failed to connect to remote SSH server: Invalid command: git-lfs-transfer ThomasJannaud/app-langues.git upload You appear to be using ssh to clone a git:// URL. Make sure your core.gitProxy config option and the GIT_PROXY_COMMAND environment variable are NOT set.
- 参考过git代理配置及Git LFS SSH连接相关问题
- 单独执行
ssh git@github.com "git-lfs-authenticate xxx/myrepo.git upload"返回正常授权JSON及200状态码 - 已配置全局替换规则:
git config --global url.https://github.com/.insteadOf git://github.com/
当前困惑
- 严格按标准流程操作,但
git lfs ls-files无输出,.db文件未被LFS追踪 - 推送触发大文件超限错误,证实文件未通过LFS上传
- 单独验证SSH的Git LFS授权命令有效,但推送过程中Git LFS的SSH连接失败
更新信息
远程仓库地址配置:
> git remote -v origin git@github.com:username/myrepo.git (fetch) origin git@github.com:username/myrepo.git (push)
完整Git配置列表:
> git config --list --show-origin file:/Applications/Xcode.app/Contents/Developer/usr/share/git-core/gitconfig credential.helper=osxkeychain file:/Applications/Xcode.app/Contents/Developer/usr/share/git-core/gitconfig init.defaultbranch=main file:/Users/thomas/.gitconfig user.name=Thomas file:/Users/thomas/.gitconfig user.email=myemail@... file:/Users/thomas/.gitconfig url.https://github.com/.insteadof=git://github.com/ file:.git/config core.repositoryformatversion=0 file:.git/config core.filemode=true file:.git/config core.bare=false file:.git/config core.logallrefupdates=true file:.git/config core.ignorecase=true file:.git/config core.precomposeunicode=true file:.git/config lfs.repositoryformatversion=0 file:.git/config remote.origin.url=git@github.com:username/myrepo.git file:.git/config remote.origin.fetch=+refs/heads/*:refs/remotes/origin/* file:.git/config branch.master.remote=origin file:.git/config branch.master.merge=refs/heads/master
内容的提问来源于stack exchange,提问作者Thomas
相关产品推荐
相关产品推荐

