github上传文件及其问题解决

1. github上上传文件夹

首先在github上create a new repository,填写repository name,根据需求选择public、private,勾选 Add a README file,最后确认
在这里插入图片描述
在本地文件夹里创建一个新的文件夹,进入这个新文件,再输入git init

mkdir xxx
cd xxx
git init

在这里插入图片描述
找到自己的repository,复制自己的repository
在这里插入图片描述
输入

git clone xxxx

把要上传的文件移入这个git clone的文件夹里,进入这个文件夹,输入

cd xxx
git add .

在这里插入图片描述

再输入git commit -m "first commit",双引号里面是写入备注,以方便后面在github上面能看到上传记录,根据这个备注得知做了什么修改

git commit -m "first commit"

最后

git push origin main

2. ‘’ does not have a commit checked out

原因参考https://stackoverflow.com/questions/56873278/how-to-fix-error-filename-does-not-have-a-commit-checked-out-fatal-adding
出现这种问题是因为你准备git add这个文件夹的时候,在你上传的这个文件夹里面有一个子目录有.git目录
在这里插入图片描述
上面会提示你那个文件夹里有.git,首先用git reset .取消之前git add .的所有文件

git add

再进入那个文件夹,用ls -la就可以查看所有文件,

ls -la

包括隐藏文件.git,若显示了有.git文件,用rm -fr .git删除即可

rm -fr .git

在这里插入图片描述

3. this exceeds GitHub’s file size limit of 100.00 MB

主要是因为文件过大,下载git lfs即可
https://docs.github.com/zh/repositories/working-with-files/managing-large-files/installing-git-large-file-storage
我的大文件是心理学与生活…,根据对应的大文件名修改即可,在输入commit的备注信息,最后根据是main还是master进行push,我这里是main,因此输入git push origin main

git lfs track 心理学与生活第19版中文版.pdf
git add 心理学与生活第19版中文版.pdf
git commit -m "add bigfile-心理学与生活第19版中文版.pdf"
git push origin main

我在输入这些命令时发现了以下报错

batch response: This repository is over its data quota. Account responsible for LFS bandwidth should purchase more data packs to restore access.

此处参考https://stackoverflow.com/questions/62905325/this-repository-is-over-its-data-quota-account-responsible-for-lfs-bandwidth-sh
因此还需要在github上的repository进行设置,(我设置了还是没解决,这个后面再说)
在这里插入图片描述

  1. Fork the repo to one of your users
  2. Go to repo settings
  3. Find “Include Git LFS objects in archives” under the Archives section and check it
  4. Go to the Danger Zone section, select “Archive this repository”
  5. Confirm and authorize.
  6. Return to the archived repository. 7 .Download as .zip
  7. Download will pause for a minute or so before it starts downloading lfs objects. Wait and it should continue.

4. error: src refspec master does not match any

参考https://blog.csdn.net/qq_43142509/article/details/124182138
现在github的默认分支为main,而我输入的命令是git push origin master,需要提交到main,而不是master,将master改成main即可

git push origin master
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值