GitHub上传大于25M的文件

  • 一、下载Git客户端
  • 二、下载Git LFS (Git Large File)客户端
  • 三、上传文件


一、下载Git客户端

1、官网链接:https://github.com/git-for-windows/git/releases

找到所需的版本,点击下载。

github仓库 文件多大_上传


2、安装过程:基本上是一路默认Next(根据版本不同会有差别,但基本相同)。可参考Git的安装步骤

二、下载Git LFS (Git Large File)客户端

1、官网链接:https://github.com/git-lfs/git-lfs/releases

找到所需的版本,点击下载。

github仓库 文件多大_git_02

2、安装过程:双击安装应用程序

3、错误情况:

github仓库 文件多大_github仓库 文件多大_03


说明Git和Git LFS的版本不对应,建议使用Git 2.36.1和Git LFS 3.1.4。

三、上传文件

1、准备工作:
(1)在电脑中自选目录新建一个文件夹(例:D:/Git/test_pb);
(2)在GitHub上新建一个仓库(Repositories)。

2、打开Git Bash或cmd,进入刚刚新建的文件夹:

cd D:\Git\test_pbtxt

回车

github仓库 文件多大_上传_04


3、初始化仓库:

git init

回车

github仓库 文件多大_上传_05


4、安装git lfs(一个仓库里面执行一次就好了)

git lfs install

回车

github仓库 文件多大_运维_06


5、将需要上传的文件放置test_pbtxt文件夹中,跟踪一下你要上传(push)的文件或指定文件类型(以指定文件weights.pb为例)

git lfs track "weights.pb"

回车

github仓库 文件多大_github仓库 文件多大_07


6、添加.gitattributes(配置文件,缺少它执行其他git操作可能会有问题)

git add .gitattributes

回车,将在文件夹中看到

github仓库 文件多大_运维_08


7、添加要上传(push)的文件

将文件拷贝至test_pbtxt文件夹,输入如下代码,再回车

git add weights.pb

如果文件名中间有空格,用双引号引起来,如git add “CNN weights.pb”

github仓库 文件多大_github_09


8、提交(commit)

git commit -m “任意文字”

github仓库 文件多大_上传_10

“任意文字”是用于最终上传成功后github上文件的描述:

github仓库 文件多大_运维_11


9、将本地与新建仓库进行配对

git remote add origin https:github.com/****/****.git

其中,https:github.com//.git 这你自己新建的仓库地址

10、生成密钥,放在远程仓库

ssh-keygen -t rsa -C 38*******@qq.com

回车

  • 若没问题,会出现下图,回车三次即可
  • github仓库 文件多大_github仓库 文件多大_12

  • 打开新生成密钥的文件的地址,可以看到:
  • github仓库 文件多大_github仓库 文件多大_13

  • 打开id_rsa.pub文件并复制其中内容。
  • 若出现错误
    报错信息:输入ssh-keygen指令提示不是内部或外部程序
    原因:没有进行Git环境变量的配置
    解决方法:打开Git安装位置,找到usr目录下的bin目录,复制地址
    (1)选择系统环境变量,点击新建输入
  • github仓库 文件多大_运维_14

  • (2)打开系统环境变量下的Path,点击新建:输入Git地址
  • github仓库 文件多大_github仓库 文件多大_15

11、在GitHub上新建SSH key

操作:

(1)

github仓库 文件多大_上传_16


(2)

github仓库 文件多大_github仓库 文件多大_17

12、让上传看起来更连续,而不是多出很多无用的merge commit

git pull --rebase origin master

回车

github仓库 文件多大_运维_18

有可能出现如下错误:

  1. 报错信息:OpenSSL SSL_read: Connection was aborted, errno 10053
    问题原因:git 默认的缓存区太小了,增加缓冲器
    解决方案:
git config --global http.postBuffer 524288000
  1. 报错信息:fatal: Could not read from remote repository.
    解决方案:
git pull --rebase origin main
  1. 报错信息:fatal: refusing to merge unrelated histories
    解决方案:
git pull --rebase origin main --allow-unrelated-histories

13、正式上传

git push -u origin master

回车(静静等待即可,会受网络影响)

github仓库 文件多大_git_19


14、上传成功