使用git上传代码到github

基本使用

1、设置用户名及邮箱

git config user.name"你的用户名"
git config user.email"xxx@xx.com"


2、查看配置

git config -l

3、生成秘钥

ssh-keygen -t rsa

根据上图中红框标出的id_rsa.pub地址,找到它,使用txt文件打开,复制里面的内容(该内容就是SSH)。在github上配置SSH。

4、测试连接

ssh -T git@github.com

5、github上添加仓库

6、将本地文件上传到github

①初始化

git init

②将本地仓库与github关联

git remote add origin "github地址"

③将所有文件提交到暂存区

git add .

④提交更改到服务器(双引号里面是注释,可随意输入)

git commit –m "first commit"

⑤指定分支

git branch -M main

⑥先pull,将服务器最新的更改获取到本地

git pull --rebase origin main

⑦再push,将本地主分支更新推到远程

git push -u origin main

可能出现的错误

1、如果在commit出现错误error: pathspec ‘-m‘ did not match any file(s) known to git,则执行

git commit –m "first commit" #

再执行⑥、⑦步骤。

2、如果在push时出现remote: error: File XXX.pkl is 418.05 MB; this exceeds GitHub's file size limit of 100.00 MB,则执行

git filter-branch --force --index-filter 'git rm -rf --cached --ignore-unmatch XXX.pkl' --prune-empty --tag-name-filter cat -- --all

再执行⑦步骤。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值