上传本地代码到github详解

作者: 萤火驻守心间 | 来源:发表于2022-04-06 11:43 被阅读0次

    一、(无github账号的)注册,登录github,创建repository,设置访问权限

    image.png
    image.png
    image.png
    复制https地址https://github.com/loveGithubs/test1

    二、建立git仓库
    2.1、cd到本地项目目录,执行git命令
    git init
    2.2、将项目的所有文件添加到仓库中
    git add .
    2.3、提交代码到仓库
    git commit -m "commit code"
    2.4、本地仓库关联github
    git remote add origin https://github.com/loveGithubs/test1
    注意:链接地址不要带.git,否则可能报错fatal: unable to access 'https://github.com/loveGithubs/test1.git/': LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443
    2.5、上传到git远程仓库
    git push -u origin main
    成功:

    image.png

    如遇到remote: Support for password authentication was removed on August 13, 2021,即密码凭证从2021年8月13日开始无法使用,必须用token的报错。解决方案:
    1、登录自己的github账号,选择settings


    image.png

    2、选择developer settings


    image.png
    3、选择Personal access tokens和Generate new token
    image.png
    4、设置token的有效期,访问权限等

    注意:要使用token从命令行访问仓库,请选择repo;要使用token从命令行删除仓库,请选择delete_repo


    image.png
    4.1、点击生成令牌 Generate token
    image.png
    5、复制token,粘贴到在push代码时要求输入密码的位置,push即可
    image.png

    相关文章

      网友评论

        本文标题:上传本地代码到github详解

        本文链接:https://www.haomeiwen.com/subject/otsrsrtx.html