目录
前言
准备工作
教程来啦!!!
第一部分
第二部分
链接说明
前言
哈喽,大家好,我是木易巷。
今天给大家分享一下:如何使用GitHub创建自己的个人网站?
![](https://img-blog.csdnimg.cn/img_convert/0e998bf9ef62fde63276595d932ab9e5.jpeg)
准备工作
需要使用GitHub,当然前提得有GitHub的账号。没有的话,赶紧去注册一个!
GitHub官网:https://github.com/
注册后,登录进入~
教程来啦!!!
第一部分:
1、点击页面右上角个人头像图标
![](https://img-blog.csdnimg.cn/img_convert/cefba9e9b3f4f8b30a82a9135b8bc16a.png)
2、新建仓库
3、给仓库起个名字【注意 容易出错】
![](https://img-blog.csdnimg.cn/img_convert/0d2b4f00e3d50742191e8755db0b11a9.jpeg)
4、输完名字,下面Description是项目描述,下面的就让他默认,不用管,直接点击:Create repository 就可以了。
5、最后创建完 是这个样子滴
好啦,目前进度30% 继续加载~
接下来,咱们要使用git命令来操作。
如果没有安装git的小伙伴,可以去git官网下载安装适合自己系统的版本。
git官网:https://git-scm.com
第二部分:
1、在电脑上选择一个合适的路径,比如我选择的是D盘,新建一个文件夹,并给它取个名字。
![](https://img-blog.csdnimg.cn/img_convert/6ee6206f4fa21a57b46dfd4bafc73132.png)
2、打开Git程序
![](https://img-blog.csdnimg.cn/img_convert/92f749faf4e342b756df76c2c499bec6.jpeg)
3、进入新建的文件夹目录当中
![](https://img-blog.csdnimg.cn/img_convert/e9ab6426d284adb18043060848703bd1.png)
4、复制GitHub仓库地址,如图
![](https://img-blog.csdnimg.cn/img_convert/3dcc46a23cc314541b21830cc8e3098f.png)
5、在git命令行中输入:【git clone + 仓库地址】,将仓库克隆到本地。
![](https://img-blog.csdnimg.cn/img_convert/1d81475857a2c9caaa2ebf046cb85277.png)
如果报错,遇到问题:fatal: unable to access ‘https://github.comxxxxxxxxxxx’: Failed to connect to xxxxxxxxxxxxx
运行:git config --global --unset http.proxy 命令
重启Git Bash
![](https://img-blog.csdnimg.cn/img_convert/92f749faf4e342b756df76c2c499bec6.jpeg)
再次运行git命令!
![](https://img-blog.csdnimg.cn/img_convert/d7bb261357f1d0eb1b2560acf6b7514f.png)
成功之后,说明克隆仓库成功。在该目录下面刷新,就会看到生成的一个文件夹:
![](https://img-blog.csdnimg.cn/img_convert/d33ca18e6c7a234bd5492633c02a1a31.png)
现在的文件夹是空的,双击打开之后,就可以把你的项目文件放进去啦!!!
![](https://img-blog.csdnimg.cn/img_convert/f0f65646aa077fff5bc18396b29d2fe5.png)
6、之后,使用git命令 进入到生成的文件夹【cd +路径】
![](https://img-blog.csdnimg.cn/img_convert/3c495e280370f90ec5af1c903155914c.png)
7、继续输入:【git add .】 //注意这个点 意思是 给仓库添加文件
![](https://img-blog.csdnimg.cn/img_convert/77409498e79e5e54747fa01195d1fa44.png)
8、继续输入 【git commit -m "这里是注释" 】 意思是 给这个上传过程 起个名称
![](https://img-blog.csdnimg.cn/img_convert/4ff65dd830bc4fc21ad864947c4618db.png)
9、继续输入 【git push】 开始上传~~~
会提示输入账号和密码(GitHub账号和密码)
![](https://img-blog.csdnimg.cn/img_convert/f5c4adc27bcf44395e885fdf38d69e49.png)
![](https://img-blog.csdnimg.cn/img_convert/804c4e05d2b925325e8f4d61a9afbc77.jpeg)
![](https://img-blog.csdnimg.cn/img_convert/10bd30521f1bb3d77f0204f044501977.png)
![](https://img-blog.csdnimg.cn/img_convert/91fc2223df4255deb41fa932dc343f30.png)
八嘎!!又出现了问题,报错:
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.br
它的大概意思就是自 2021年 8 月 13日开始,GitHub中通过 用户名 + 密码的认证方式被移除了,只能通过个人访问码的方式进行认证。
解决方法【创建个人访问码】:
1、进入 Github 主界面,点击右上角头像,选择 “Seeting”,进入设置界面。
![](https://img-blog.csdnimg.cn/img_convert/08661dd38e883994e2eb3c330d4a7912.png)
2、在左边的导航栏目里面选择 “Developer seetings”,进入开发者设置页面。
![](https://img-blog.csdnimg.cn/img_convert/f8332cfd1cf82737ee72e056c3344602.png)
![](https://img-blog.csdnimg.cn/img_convert/9bd7316f1f27867d4a120596dc7955dd.png)
3、选择 “Personal access tokens”, 点击 “Generate new token”。
![](https://img-blog.csdnimg.cn/img_convert/9755ad2bb7f2195be1df34904710cc97.png)
你会看到如下界面:
![](https://img-blog.csdnimg.cn/img_convert/72394448fc8cd2535cc3524c9fa8dcd4.png)
4、输入 “note”,选择 “Expiration(有效期)”,你可以自定义有效时间。下面的复选框没有特别的要求的话可以都勾上, 然后到页面最下面,点击“Generate Token”,产生对应的个人访问码。
![](https://img-blog.csdnimg.cn/img_convert/b0f6acdece68d7bf3031198dbe02c065.png)
![](https://img-blog.csdnimg.cn/img_convert/2bc1cc567ad7866687aae89c60c5bc3d.png)
5、现在你可以看到产生的个人访问码了,复制它。建议保存到一个文件里,保存好。
![](https://img-blog.csdnimg.cn/img_convert/8896983b6ef0f193e643e50c8b57f40a.png)
6、搞定。
10、再次执行推送命令,这时会提示输入用户名,按照正常的输入即可;在输入用户名之后将会提示输入密码,这里就需要输入之前产生的个人访问码(Personal access token)了,直接复制输入即可。
![](https://img-blog.csdnimg.cn/img_convert/20db8ef1cca0f019c8af084fe4e3fd20.png)
![](https://img-blog.csdnimg.cn/img_convert/b9436b7358d9316764cd8f4d5062032e.png)
11、成功之后,我们打开GitHub看一下
![](https://img-blog.csdnimg.cn/img_convert/203638e744d30d2a2039881231bee604.png)
12、成功成功!!!
链接说明
我地址是:https://yac1217.github.io/【可以复制到浏览器打开】
链接就是:https://github的用户名.github.io
自行替换用户名~
![](https://img-blog.csdnimg.cn/img_convert/ecc5cc92099ac6ed8c4d10ed916b0909.png)
如果觉得这个网址不好听,不好记,可以自己去购买域名进行配置。
但是由于github不太稳定,不太建议。