github文件上传及github pages博客搭建教程
一、与github建立连接
2.桌面新建文件夹【github】,右键“git bash here”
3.注册github账号,新建仓库“new repository”,勾选“Initialize this repository with a README”
4.生成新的SSH key,需要输入密钥时直接回车即可
$ ssh-keygen -t rsa -C "邮件地址@youremail.com"
5.在【id_rsa.pub】文件中找到新生成的ssh key,复制并粘贴到github的【settings】-【Add Key】
6.测试是否成功
$ ssh -T git@github.com
第一次连接时需要输入“yes”回车即可
7.设置账号信息
$ git config --global user.name "你的名字" $ git config --global user.email "your_email@youremail.com"
二、上传文件到github
1.在github创建仓库
2.本地克隆仓库
git clone https://github.com/nwsci/wangyi.git
3.如果之前创建仓库时勾选了“Initialize this repository with a README”,直接进入第四步;否则需要创建README.md
git init touch README.md git add README.md git commit -m 'first_commit' git remote add origin https://github.com/findingsea/myRepoForBlog.git git push origin master
4.push文件
git add . git commit -m '文件名' git remote add origin https://github.com/nwsci/wangyi.git git push origin master
注意:第三个命令执行时如果报错“fatal: remote origin already exists”,则先执行
git remote rm origin
第四个命令执行时如果报错“error:failed to push som refs to.......”,则先执行
git pull origin master
三、使用github pages建立博客
1.在github创建新项目,名为“username.github.io”
2.使用git安装hexo
$ npm install -g hexo
3.在本地新建【hexo】文件夹,右键“git bash here”
$ hexo init
4.执行以下命令,然后到浏览器访问“localhost:4000”看看
$ hexo g
$ hexo s
注意:执行命令时遇到报错“ERROR Try running: 'npm install hexo --save'”,按提示用以下命令安装一下,再重新尝试上面命令
npm install hexo --save
5.复制主题
$ git clone https://github.com/A-limon/pacman.git themes/pacman
或者
$ git clone https://github.com/cnfeat/cnfeat.git themes/jacman
6.启用主题
修改【hexo】目录下的【config.yml】配置文件中的 theme 属性,将其设置为pacman。同时请设置stylus属性中的compress值为true。
7.更新主题
$ cd themes/jacman
$ git pull
8.本地环境搭建
9.本地查看调试
$ hexo g #生成
$ hexo s #启动本地服务,进行文章预览调试
或者直接使用组合命令
$ hexo d -g
如果您看完本篇感觉不错,请点击下方的【推荐】支持一下博主!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南