完美解决github上传大文件超过100mb和github上传文件的坑

github上传文件以及一些坑

上传文件到github

正常来说:
1.先在自己的github上创建一个仓库并且需要配置好ssh公钥
2.常规操作

#这里是写一个字符串到README.md文件里(如果你创建的那个仓库没有点击初始化REAME.md的话,可以执行这个操作)
echo "# face-recognition" >> README.md
#初始化
git init
#添加自定义文件到暂存区
git add README.md
#提交
git commit -m "first commit"
#绑定远程仓库   就是你之前在github上创建的仓库地址
git remote add origin https://github.com/gkho/face-recognition.git
#推送到远程仓库origin  的master分支
git push -u origin master

坑:

如果你初始化仓库的时候点击了Initialize this repository with a README
那么需要先git pull 然后再推送git push

 git pull origin master --allow-unrelated-histories

 #然后合并本地仓库再推送
 git merge origin master
 git push -u origin master
 
 

git pull错误 解决方法看git pull错误解决

github解决大文件的上传

#设置缓存 这是500mb
git config http.postBuffer 524288000
# 1、安装git-lfs

git lfs install

# 2、跟踪一些文件,那么上传大小就会变少  比如可以跟踪py结尾的文件 git lfs track "*.py"
git lfs track "你要跟踪的大文件的拓展名"

# 3、push常规操作
git add  你要上传的大文件
git commit -m "add large file"
git push -u origin master

可能还是会错
在这里插入图片描述
那么输入

git config lfs.https://github.com/468336329Zc/face-recognition.git/info/lfs.                                                                                                                          locksverify false
#然后再次push
git push -u origin master

猜你喜欢

转载自blog.csdn.net/weixin_43919632/article/details/103552220
今日推荐