[git使用手册]Github上传文件及解决main主分支问题和各类报错error

  • 上传流程
git init //初始化仓库
git add . //添加文件到本地仓库
git branch -M main //选择main分支,可以改名上传其它分支
git commit -m "first commit" //添加文件描述信息
git remote add origin https://github.com/xxx/xxxx.git //链接远程仓库,创建主分支
git pull origin main // 把本地仓库的变化连接到远程仓库主分支
git push -u origin main //此处上传的是main分支
  • main主分支问题

关于main主分支问题,主要在于git push -u origin main这句,由于大部分教程用的master分支作为样例,所以导致我们大家可能理解有所偏差,这里改为main即可。

  • 推送更新出现错误: hint: Updates were rejected because the tip of your current branch is behind
    hint: its remote counterpart. Integrate the remote changes (e.g.
    hint: ‘git pull …’) before pushing again.
    hint: See the ‘Note about fast-forwards’ in ‘git push --help’ for details.
    在这里插入图片描述
git push -f origin main //强制push就成功了。

但大家不要随便用-f的操作,因为f意味着强制push,会覆盖掉远程的所有代码。

  • error: remote origin already exists.
git remote rm origin //先删除远程 Git 仓库
git remote add origin xxx //再添加远程 Git 仓库
  • OpenSSL SSL_read: Connection was reset, errno 10054
git config --global http.sslVerify "false"
  • Failed to connect to github.com port 443: Timed out
git config --global --unset http.proxy

若发现其余错误,陆续更新,也欢迎大家私信联系我或评论。loading..

  • 4
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

richardxp888

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值