一、(无github账号的)注册,登录github,创建repository,设置访问权限
![](https://img.haomeiwen.com/i27469387/d02f513bdb18499d.png)
![](https://img.haomeiwen.com/i27469387/45b10767a764bf98.png)
![](https://img.haomeiwen.com/i27469387/9b0b6b77fc70f0d2.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
成功:
![](https://img.haomeiwen.com/i27469387/b55aedee268501a7.png)
如遇到remote: Support for password authentication was removed on August 13, 2021,即密码凭证从2021年8月13日开始无法使用,必须用token的报错。解决方案:
1、登录自己的github账号,选择settings
![](https://img.haomeiwen.com/i27469387/f0fabb72f468c60a.png)
2、选择developer settings
![](https://img.haomeiwen.com/i27469387/ab2befc778a1ba88.png)
3、选择Personal access tokens和Generate new token
![](https://img.haomeiwen.com/i27469387/e9b486ba06f8f84c.png)
4、设置token的有效期,访问权限等
注意:要使用token从命令行访问仓库,请选择repo;要使用token从命令行删除仓库,请选择delete_repo
![](https://img.haomeiwen.com/i27469387/cb4c8371e28ffa40.png)
4.1、点击生成令牌 Generate token
![](https://img.haomeiwen.com/i27469387/48983d2a18241fd5.png)
5、复制token,粘贴到在push代码时要求输入密码的位置,push即可
![](https://img.haomeiwen.com/i27469387/cc338d1447062c46.png)
网友评论