vscode git 推送失败分析
vscode
通过GUI
来操作git
比较方便,直接在git面板操作就行了。
在上传深入解析Windows操作系统
时失败了,查看OUTPUT
,没有什么有用的提示,多上传几个文件发现是对大文件的限制(100M
)。
解决办法
常规
当上传文件大于100M
时,要用LFS
插件即Git Large File Storage
- 安装插件
git lfs install
- 版本回退
git reflog #查看所有本地版本,q退出
git reset --hard db804cf #db804cf为第一次添加大文件的sha值开头的一部分
将Windows/深入解析Windows操作系统_第6版.zip
复制到上一级目录(..
)
恢复GitHub版本到本地
git reset --hard origin/master
将Windows/深入解析Windows操作系统_第6版.zip
移动到git目录,添加下面内容到.gitignore
!Windows
Windows/*
- 添加文件
git lfs track "Windows/深入解析Windows操作系统_第6版.zip"
git add .gitattributes
这里Windows/深入解析Windows操作系统_第6版.zip
是大文件
- 正常推送
git add "Windows/深入解析Windows操作系统_第6版.zip" -f
git commit -m "Git Large File"
git push origin master
用-f
覆盖.gitignore
的过滤限制
发布软件
在项目添加releases标签,文件大小<2G
。
参考链接
git-lfs
https://git-lfs.github.com/
GitHub Help
https://help.github.com/en/articles/working-with-large-files
gitignore
https://git-scm.com/docs/gitignore
stackoverflow
https://stackoverflow.com/questions/16288176/your-branch-is-ahead-of-origin-master-by-3-commits