• github文件上传及github pages博客搭建教程


    一、与github建立连接

    1.安装node.jsgit

    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.本地环境搭建

    参考一步步在GitHub上创建博客主页(4)

    9.本地查看调试

    $ hexo g #生成
    $ hexo s #启动本地服务,进行文章预览调试

    或者直接使用组合命令

    $ hexo d -g

     更多参考一步步在GitHub上创建博客主页-最新版

  • 相关阅读:
    安卓查询当前所在地天气及查询地区(城市)代码cityCode localCode
    文件读写IO
    【桌面虚拟化】之三 Persistent vs NonP
    Android软件开发之常用系统控件界面整理
    Spring 3.x企业应用开发实战(11)----基于@AspectJ配置切面
    Java之Static静态修饰符详解
    OWASP
    2001中美黑客大战
    能"干掉"苹果的中国"黑客"
    Roy Li的学习和成长自传
  • 原文地址:https://www.cnblogs.com/newgold/p/4983744.html
Copyright © 2020-2023  润新知