git+hexo+gitbook入门指南

为了硬凑字数写的小短文:

本文内容包含:

1、记录安装过程中的报错;

2、记录git的使用命令;

3、记录hexo的安装及next主题的优化;

4、记录gitbook的安装及优化;

5、记录markdown的安装及优化;

解决代码报错

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
## 
$ git clone https://github.com/wdg1111/wdgreact.git
Cloning into 'wdgreact'...
fatal: Unsupported SSL backend '“openssl”'. Supported SSL backends:
openssl
schannel
出现上面的报错:

解决方法
git config --global --unset http.sslBackend


## 解决报错:
git.exe pull --progress --no-rebase -v "origin"fatal: unable to access 'https://github.com/konsumer/arduinoscope.git/': error setting certificate verify locations:
CAfile: D:\Program Files\Git\mingw64/bin/curl-ca-bundle.crt
CApath: none
————————————————

git config --system http.sslcainfo "D:\bclang\R-4.0.5\library\openssl\curl-ca-bundle.crt"

(注意修改为正确的文件路径)或
git config --system http.sslverify false

# 暂时先以这种方法解决问题;
我使用git config --system http.sslverify false 命令解决问题。


## 报错解决:
Git报错解决:OpenSSL SSL_read: Connection was reset, errno 10054 错误解决
# 打开Git命令页面,执行git命令脚本:修改设置,解除ssl验证
git config --global http.sslVerify "false"


## hexo - d 无法推送:
deploy: ## 注意下面代码的相对位置;错位后不能推送;
type: git
repo: https://github.com/nicheerfeng/nicheerfeng.gitihub.io.git
branch: master

## 报错记录:解决git push时出现Failed to connect to github.com port 443: Timed out
# 这里可能的原因是本地的代理或者host出现问题;
# 检测方法:第一是取消代理,仅使用本地host;或者更改代理:
# 解决办法参见:
https://www.it610.com/article/1288132904815210496.htm
# 查询是否使用代理
git config --global http.proxy
git config --global https.proxy
或者
env|grep -I proxy
## 取消代理设置
git config --global --unset http.proxy
git config --global --unset https.proxy


## 报错记录:
# 解决:
INFO Validating config
ERROR Deployer not found: git
# 方法:
$ hexo d
npm install --save hexo-deployer-git


hexo安装工作步骤

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
node -v	#查看node版本
npm -v #查看npm版本
npm install -g cnpm --registry=http://registry.npm.taobao.org #安装淘宝的cnpm 管理器
cnpm -v #查看cnpm版本
cnpm install -g hexo-cli #安装hexo框架
hexo -v #查看hexo版本
mkdir blog #创建blog目录
cd blog #进入blog目录
sudo hexo init #生成博客 初始化博客
hexo s #启动本地博客服务
http://localhost:4000/ #本地访问地址
hexo n 我的第一篇文章 #创建新的文章
#返回blog目录
hexo clean #清理
hexo g #生成
#Github创建一个新的仓库 YourGithubName.github.io
cnpm install --save hexo-deployer-git #在blog目录下安装git部署插件
----
#配置_config.yml
-----
# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
type: git
repo: https://github.com/YourGithubName/YourGithubName.github.io.git
branch: master
-----。
hexo d #部署到Github仓库里
https://YourGithubName.github.io/ #访问这个地址可以查看博客

git clone https://github.com/litten/hexo-theme-yilia.git themes/yilia #下载yilia主题到本地

#修改hexo根目录下的 _config.yml 文件 : theme: yilia

hexo c #清理一下
hexo g #生成
hexo d #部署到远程Github仓库

hexo server -g 本地4000端口预览;

## 远程更新到github之前,本地win;
# 需要先配置ssh文件;


## 获取github的ssh网页地址:
在建立的仓库中选择code,然后点击ssh即可;


hexo优化

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
###################### 主题优化 #####################
# 安装及下载主题:
git clone https://github.com/next-theme/hexo-theme-next themes/next

## 主题基本内容优化

参见:
方法1:https://www.jianshu.com/p/3af2687c01b4

方法2:https://blog.csdn.net/prefectjava/article/details/111192741

## 双语修改:
language_switcher: true

# 图片保存:
mn4.jpg 全文背景;

## 主题优化报错:
在将主题优化后,到github上面之后,数据显示不全,或乱码:
# 解决方法:
修改根目录下的_config.yml,然后将url改为你的gihub网站;

##################### 配置图床 ########################
## 使用picgo:
## 注意token的最长有效期为90天,也即3个月;

# 相关参数:
仓库名:buyishusheng/datapicture
分支名:master
token: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
指定储存路径:img/
设计自定义域名:https://github.com/buyishusheng/datapicture/master


## 注意添加图传的 markdown形式后,需要在其后面添加:
?raw=true

### ################### hexo提交markdown ##############

## 相关配置:
title: Hello World
date: 2019-06-28 22:36:00
categories: hexo
tags:
- hexo
- others

##

git 使用及进阶

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
## git使用:
## 使用git:

## 查看个人配置和全局配置:
git config --list : 按q退出;

# 如果要求修改某个参数,直接百度即可;
# 例如master 改为 main
git config --global init.defaultBranch main
## 查看个人配置参数:
C:\Users\admin\.gitconfig

## git的分支思想:
分支在实际中有什么用呢?假设你准备开发一个新功能,但是需要两周才能完成,第一周你写了50%的代码,如果立刻提交,由于代码还没写完,不完整的代码库会导致别人不能干活了。如果等代码全部写完再一次提交,又存在丢失每天进度的巨大风险。

现在有了分支,就不用怕了。你创建了一个属于你自己的分支,别人看不到,还继续在原来的分支上正常工作,而你在自己的分支上干活,想提交就提交,直到开发完毕后,再一次性合并到原来的分支上,这样,既安全,又不影响别人工作。

其他版本控制系统如SVN等都有分支管理,但是用过之后你会发现,这些版本控制系统创建和切换分支比蜗牛还慢,简直让人无法忍受,结果分支功能成了摆设,大家都不去用。

但Git的分支是与众不同的,无论创建、切换和删除分支,Git在1秒钟之内就能完成!无论你的版本库是1个文件还是1万个文件。


## 相关流程记录:
1 、在github创建远程仓库;
2、使用git clone 远程仓库;ssh格式的;

3、 根据远程仓库中的文件,修改自己的代码或者增添新的文件;
4、 使用git add "添加指定文件" 或者add .增加所有文件(注意空格);
5、 使用git commit -m "用于记录测试",添加本次将信息拷贝到缓存的分支记录信息;
5.1 理论上这里每次应该可以回滚,查看所有提交的历史记录;

6、上传文件到github对应的仓库;
git push -u origin main ## 注意origin main为固定格式,不可改变;

## git进阶:
1、查看修改文件的历史记录:
git log --follow -p ddd.txt ##仅包含修改部分;

2、查看历史回滚记录:
git log

3、创建分支;
# 目的是有一个总分支,然后在子分支上工作;将子分支合并到总分支中;
$ git checkout -b iss53
Switched to a new branch "iss53"
该命令为下面两条命令的简写:
$ git branch iss53
$ git checkout iss53
3.1 删除分支:
git branch -D hotfix
3.2 删除远程分支:
git push origin --delete new_a


4、 切换分支:
git checkout iss53 ## 子分支;
git checkout main ## 总分支;

5、分支合并:
5.1 子分支合并到主分支?
git merge hotfix # 其中hotfix是子分支,默认即合并;

## 如果子分支与总分支出现合并冲突,则需要手动解决;

6、查看所有分支;
git branch -a

如何使用gitbook来写书;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
## 如何使用gitbook来写书;
https://blog.csdn.net/weixin_39637597/article/details/104456912?utm_medium=distribute.pc_relevant.none-task-blog-baidujs_title-2&spm=1001.2101.3001.4242

## gitbook使用指南:
安装:
首先安装nodejs;
然后使用rpm安装gitbook;
npm install -g gitbook-cli
gitbook -V ## 会自动查看gitbook并更新软件;


## 初始化命令:
gitbook init 生成两个初始文件;readme.md对书籍的简单介绍;summary为书籍目录结构;
gitbook server:预览书目;

## 构建目录:
gitbook子目录写作:
* [zilu](zilu.md)
- [zilu](zilu.md)
- (hrttps)

## 安装插件:
在该文件夹下生成book.json文件;
并在npm下搜索相关插件的命令(https://www.npmjs.com/),把对应的代码复制到上面即可;
复制完代码后执行, gitbook install 安装对应的插件;
最后,在进行gitbook serve即可;
# 对应的添加评论插件;
https://www.npmjs.com/package/gitbook-plugin-comments-footer
## 其他可能有用的;
gitbook-plugin-donate(打赏按钮): https://www.npmjs.com/package/gitbook-plugin-donate

gitbook-plugin-github-buttons(GitHub按钮): https://www.npmjs.com/package/gitbook-plugin-github-buttons

gitbook-plugin-edit-link(GitHub编辑按钮): https://www.npmjs.com/package/gitbook-plugin-edit-link


## 命令合集:
gitbook init //初始化目录文件
gitbook help //列出gitbook所有的命令
gitbook --help //输出gitbook-cli的帮助信息
gitbook build //生成静态网页
gitbook serve //生成静态网页并运行服务器
gitbook build --gitbook=2.0.1 //生成时指定gitbook的版本, 本地没有会先下载
gitbook ls //列出本地所有的gitbook版本
gitbook ls-remote //列出远程可用的gitbook版本
gitbook fetch 标签/版本号 //安装对应的gitbook版本
gitbook update //更新到gitbook的最新版本
gitbook uninstall 2.0.1 //卸载对应的gitbook版本
gitbook build --log=debug //指定log的级别
gitbook builid --debug //输出错误信息


## 相关插件:
# 常用插件推荐:
https://blog.csdn.net/qq_37149933/article/details/64170653?utm_medium=distribute.pc_relevant.none-task-blog-2~default~baidujs_utm_term~default-1.searchformbaiduhighlight&spm=1001.2101.3001.4242
disqus
添加 disqus 评论插件。

* [介绍](README.md)
- [next](zil.md)

## 插件的参考写作方法:
{
"title": "编写gitbook电子书教程",
"description": "gitbook电子书教程",
"author": "sphard",
"language": "zh-hans",
"root": ".",

"plugins": [
"donate",
"github-buttons@2.1.0",
"edit-link"
],

"pluginsConfig": {
"donate": {
"wechat": "https://sphard.com/images/wechatpay.jpg",
"alipay": "https://sphard.com/images/alipay.jpg",
"title": "",
"button": "打赏",
"alipayText": "支付宝打赏",
"wechatText": "微信打赏"
},
"github-buttons": {
"repo": "darrenliuwei/gitbook",
"types": [
"star"
],
"size": "small"
},
"edit-link": {
"base": "https://github.com/darrenliuwei/gitbook/edit/master",
"label": "Edit This Page"
}
}
}

################## gitbook写作知识进阶 ########################
https://www.jianshu.com/p/a3f2316aee77

markdown语法补充知识

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
## 插入图片和视频的语法:
# 直接插入:![tmgar](对应网页地址)
# 修改尺寸插入:
<img src= "对应的网页地址或者绝对地址"width ="100",height="200">

## 插入视频,是通过分享,或者嵌入式链接,直接复制即可;

## 字体添加颜色:
<font color="red">红色文字(此部分输入的是文本文件)</font>

## 插入网页:
<http>

## 转行
<br>

npm使用命令

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
npm get global

npm install -name-g ## 安装到全局环境中;

npm list: 查看当前目录下已经安装的所有软件;

## 安装第三方插件来更新npm对应的软件:
npm install -g npm-check-updates
ncu

## 卸载软件;
npm uninstall -g gitbook


## 解决报错;
TypeError: cb.apply is not a function
## 部分代码注释掉即可;
https://blog.csdn.net/sinat_31057219/article/details/112506883