安装Git
国内镜像下载
去找一个下载就行了
安装都是默认下一步就ok了
操作Git
首先打开Git Bash
鼠标右键就可以看到了
然后设置账户和密码
$ git config --global user.name "you name"
$ git config --global user.email "your email"
然后生成SSH秘钥
$ ssh-keygen -t rsa -C "you email"
生成后的秘钥一般在C:\Users\Administrator.ssh里面
用记事本打开id_rsa.pub,全部复制
然后返回到github里面打开设置
新添加一个SSH keys
将上面复制的内容添加进去
然后继续进行操作
创建本地仓库
$ git init
在然后选择文件添加到临时库
可以用 . 表示全部 也可以指定名字
$ git add .
然后为要提交的数据描述
$ git commit -m 'readme.txt提交'
接下来继续
$ git branch -M main
然后获取github的仓库的路径
$ git remote add origin https://github.com/dhsb-4/test.git
最后一步,提交到github仓库
$ git push -u origin main
当你执行这一步的时候千万要小心,由于2021-08-13出现的一个,个人访问令牌,所以它会弹出三个框
第一个框:让你填写自己的个人访问令牌
第二个框:填写用户名
第三个框:写着让你填写密码,但是其实要你填写个人访问令牌,不要在用登陆的密码了,要用个人访问令牌。不然会报以下错误
fatal: An error occurred while sending the request.
fatal: The request was aborted: Could not create SSL/TLS secure channel.
remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.
remote: Please see https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information.
fatal: Authentication failed for 'https://github.com/dhsb-4/test.git/'
这样ok了
个人访问令牌
找到这个