This commit is contained in:
linlongchen
2020-07-22 12:26:26 +08:00
parent e375b2b17e
commit 58abbc5525
63 changed files with 212 additions and 103 deletions

View File

@@ -1,104 +1,104 @@
--- ---
layout: post layout: post
title: "新版本gitbook配置图书预览和生成" title: "新版本gitbook配置图书预览和生成"
date: 2019-11-18 date: 2019-11-18
tags: [tool] tags: [tool]
comments: true comments: true
author: lemonchann author: lemonchann
--- ---
什么是Gitbook? 简单说就是可以把用md写的多个文档组织成**书**发布md你可以放在github管理配置gitbook关联github可以实现实时commit的预览生成。也可本地预览甚至生成各种格式文档输出的强大工具。 什么是Gitbook? 简单说就是可以把用md写的多个文档组织成**书**发布md你可以放在github管理配置gitbook关联github可以实现实时commit的预览生成。也可本地预览甚至生成各种格式文档输出的强大工具。
<!-- more --> <!-- more -->
## 安装Gitbook ## 安装Gitbook
* 安装nodejs可以去[官网](http://nodejs.cn/download/)下载对应版本 * 安装nodejs可以去[官网](http://nodejs.cn/download/)下载对应版本 Gitbook 只支持 node 6.x.x版本 。参考: https://www.jianshu.com/p/57b46db0564e
* 安装gitbook打开win cmd输入npm install gitbook-cli -g * 安装gitbook打开win cmd输入npm install gitbook-cli -g
> 常用命令: > 常用命令:
> **gitbook -V 查看版本** > **gitbook -V 查看版本**
> **gitbook serve 生成网页localhost:4000预览** - 命令输入要进到SUMMARY.md所在目录![gitbook_serve](https://github.com/lemonchann/lemonchann.github.io/raw/master/images/2019-11-18-new_gitbook_tutors/gitbook_serve.png) > **gitbook serve 生成网页localhost:4000预览** - 命令输入要进到SUMMARY.md所在目录![gitbook_serve](https://github.com/lemonchann/lemonchann.github.io/raw/master/images/2019-11-18-new_gitbook_tutors/gitbook_serve.png)
> gitbook init //初始化目录文件 > gitbook init //初始化目录文件
> gitbook help //列出gitbook所有的命令 > gitbook help //列出gitbook所有的命令
> gitbook --help //输出gitbook-cli的帮助信息 > gitbook --help //输出gitbook-cli的帮助信息
> gitbook build //生成静态网页 > gitbook build //生成静态网页
> gitbook serve //生成静态网页并运行服务器 > gitbook serve //生成静态网页并运行服务器
> gitbook build --gitbook=2.0.1 //生成时指定gitbook的版本, 本地没有会先下载 > gitbook build --gitbook=2.0.1 //生成时指定gitbook的版本, 本地没有会先下载
> gitbook ls //列出本地所有的gitbook版本 > gitbook ls //列出本地所有的gitbook版本
> gitbook ls-remote //列出远程可用的gitbook版本 > gitbook ls-remote //列出远程可用的gitbook版本
> gitbook fetch 标签/版本号 //安装对应的gitbook版本 > gitbook fetch 标签/版本号 //安装对应的gitbook版本
> gitbook update //更新到gitbook的最新版本 > gitbook update //更新到gitbook的最新版本
> gitbook uninstall 2.0.1 //卸载对应的gitbook版本 > gitbook uninstall 2.0.1 //卸载对应的gitbook版本
> gitbook build --log=debug //指定log的级别 > gitbook build --log=debug //指定log的级别
> gitbook builid --debug //输出错误信息 > gitbook builid --debug //输出错误信息
## 用Gitbook转换markdown文件生成PDF ## 用Gitbook转换markdown文件生成PDF
### 安装calibre ### 安装calibre
* 电子书生成下载依赖calibre否则会报错建议先安装[下载地址](https://calibre-ebook.com/download) * 电子书生成下载依赖calibre否则会报错建议先安装[下载地址](https://calibre-ebook.com/download)
* 配置calibre环境变量我的目录是C:\Program Files\Calibre2 * 配置calibre环境变量我的目录是C:\Program Files\Calibre2
![环境变量设置1](https://github.com/lemonchann/lemonchann.github.io/raw/master/images/2019-11-18-new_gitbook_tutors/%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F%E8%AE%BE%E7%BD%AE1.PNG) ![环境变量设置1](https://github.com/lemonchann/lemonchann.github.io/raw/master/images/2019-11-18-new_gitbook_tutors/%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F%E8%AE%BE%E7%BD%AE1.PNG)
![环境变量设置2](https://github.com/lemonchann/lemonchann.github.io/raw/master/images/2019-11-18-new_gitbook_tutors/%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F%E8%AE%BE%E7%BD%AE2.PNG) ![环境变量设置2](https://github.com/lemonchann/lemonchann.github.io/raw/master/images/2019-11-18-new_gitbook_tutors/%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F%E8%AE%BE%E7%BD%AE2.PNG)
### 生成PDF ### 生成PDF
打开win cmd命令行到SUMMARY.md所在目录执行 **gitbook pdf 生成pdf** 打开win cmd命令行到SUMMARY.md所在目录执行 **gitbook pdf 生成pdf**
> 转换PDF失败原因 > 转换PDF失败原因
1. 没有安装calibre 1. 没有安装calibre
2. 安装calibre之后需要设置环境变量C:\Program Files\Calibre2 2. 安装calibre之后需要设置环境变量C:\Program Files\Calibre2
3. [报错1](http://xcoding.tech/2018/08/08/hexo/%E5%A6%82%E4%BD%95%E4%BB%8E%E6%A0%B9%E6%9C%AC%E8%A7%A3%E5%86%B3hexo%E4%B8%8D%E5%85%BC%E5%AE%B9%7B%7B%7D%7D%E6%A0%87%E7%AD%BE%E9%97%AE%E9%A2%98/) 3. [报错1](http://xcoding.tech/2018/08/08/hexo/%E5%A6%82%E4%BD%95%E4%BB%8E%E6%A0%B9%E6%9C%AC%E8%A7%A3%E5%86%B3hexo%E4%B8%8D%E5%85%BC%E5%AE%B9%7B%7B%7D%7D%E6%A0%87%E7%AD%BE%E9%97%AE%E9%A2%98/)
## Gitbook关联github ## Gitbook关联github
**Gitbook上同步github的配置界面已经发生了变化新界面操作如下:** **Gitbook上同步github的配置界面已经发生了变化新界面操作如下:**
![gitbook空间](https://github.com/lemonchann/lemonchann.github.io/raw/master/images/2019-11-18-new_gitbook_tutors/gitbook%E7%A9%BA%E9%97%B4.png) ![gitbook空间](https://github.com/lemonchann/lemonchann.github.io/raw/master/images/2019-11-18-new_gitbook_tutors/gitbook%E7%A9%BA%E9%97%B4.png)
![关联github](https://github.com/lemonchann/lemonchann.github.io/raw/master/images/2019-11-18-new_gitbook_tutors/%E5%85%B3%E8%81%94github.png) ![关联github](https://github.com/lemonchann/lemonchann.github.io/raw/master/images/2019-11-18-new_gitbook_tutors/%E5%85%B3%E8%81%94github.png)
### 发布到github pages ### 发布到github pages
#### 关于 GitHub Pages #### 关于 GitHub Pages
>GitHub Pages 是一项静态站点托管服务,它直接从 GitHub 上的仓库获取 HTML、CSS 和 JavaScript 文件,(可选)通过构建过程运行文件,然后发布网站。 您可以在 GitHub Pages 示例集合中查看 GitHub Pages 站点的示例。 >GitHub Pages 是一项静态站点托管服务,它直接从 GitHub 上的仓库获取 HTML、CSS 和 JavaScript 文件,(可选)通过构建过程运行文件,然后发布网站。 您可以在 GitHub Pages 示例集合中查看 GitHub Pages 站点的示例。
您可以在 GitHub 的 github.io 域或自己的自定义域上托管站点。 更多信息请参阅“对 GitHub Pages 使用自定义域”。 您可以在 GitHub 的 github.io 域或自己的自定义域上托管站点。 更多信息请参阅“对 GitHub Pages 使用自定义域”。
要开始使用,请参阅“创建 GitHub Pages 站点”。 要开始使用,请参阅“创建 GitHub Pages 站点”。
#### GitHub Pages 站点的类型 #### GitHub Pages 站点的类型
有三种类型的 GitHub Pages 站点:项目、用户和组织。 项目站点连接到 GitHub 上托管的特定项目,例如 JavaScript 库或配方集合。 用户和组织站点连接到特定的 GitHub 帐户。 有三种类型的 GitHub Pages 站点:项目、用户和组织。 项目站点连接到 GitHub 上托管的特定项目,例如 JavaScript 库或配方集合。 用户和组织站点连接到特定的 GitHub 帐户。
用户和组织站点始终从名为 <user>.github.io 或 <organization>.github.io 的仓库发布。 除非您使用自定义域,否则用户和组织站点位于 http(s)://<username>.github.io 或 http(s)://<organization>.github.io。 用户和组织站点始终从名为 <user>.github.io 或 <organization>.github.io 的仓库发布。 除非您使用自定义域,否则用户和组织站点位于 http(s)://<username>.github.io 或 http(s)://<organization>.github.io。
项目站点的源文件与其项目存储在同一个仓库中。 除非您使用自定义域,否则项目站点位于 http(s)://<user>.github.io/<repository> 或 http(s)://<organization>.github.io/<repository>。 项目站点的源文件与其项目存储在同一个仓库中。 除非您使用自定义域,否则项目站点位于 http(s)://<user>.github.io/<repository> 或 http(s)://<organization>.github.io/<repository>。
[更多](https://help.github.com/cn/github/working-with-github-pages/about-github-pages) [更多](https://help.github.com/cn/github/working-with-github-pages/about-github-pages)
#### [这里](http://www.chengweiyang.cn/gitbook/github-pages/README.html)也包含推送到**github.page**的方法 #### [这里](http://www.chengweiyang.cn/gitbook/github-pages/README.html)也包含推送到**github.page**的方法
- master, 保存书籍的源码 - master, 保存书籍的源码
- gh-pages, 保存书籍编译后的 HTML 文件 - gh-pages, 保存书籍编译后的 HTML 文件
**步骤:** **步骤:**
- `gitbook build` 将书籍内容输出到默认目录,也就是当前目录下的 _book 目录 - `gitbook build` 将书籍内容输出到默认目录,也就是当前目录下的 _book 目录
![gitbook_pdf](https://github.com/lemonchann/lemonchann.github.io/raw/master/images/2019-11-18-new_gitbook_tutors/gitbook_pdf.png) ![gitbook_pdf](https://github.com/lemonchann/lemonchann.github.io/raw/master/images/2019-11-18-new_gitbook_tutors/gitbook_pdf.png)
- 创建gh-pages分支并且删除不需要的文件,仅保留git目录和 _book目录 - 创建gh-pages分支并且删除不需要的文件,仅保留git目录和 _book目录
> $ git checkout --orphan gh-pages > $ git checkout --orphan gh-pages
$ git rm --cached -r . $ git rm --cached -r .
$ git clean -df $ git clean -df
$ rm -rf *~` $ rm -rf *~`
- 然后,加入 _book 下的内容到分支中: - 然后,加入 _book 下的内容到分支中:
> $ cp -r _book/* . > $ cp -r _book/* .
$ git add . $ git add .
$ git commit -m "Publish book" $ git commit -m "Publish book"
- 将编译好的书籍内容上传到 GitHub 项目的 远程gh-pages 分支了 - 将编译好的书籍内容上传到 GitHub 项目的 远程gh-pages 分支了
> $git push -u origin gh-pages > $git push -u origin gh-pages
### 参考 ### 参考
[详细教程](https://jackchan1999.github.io/2017/05/01/gitbook/GitBook%E4%BD%BF%E7%94%A8%E6%95%99%E7%A8%8B/) [详细教程](https://jackchan1999.github.io/2017/05/01/gitbook/GitBook%E4%BD%BF%E7%94%A8%E6%95%99%E7%A8%8B/)
[官方指引-integrations-Github](https://docs.gitbook.com/integrations/github) [官方指引-integrations-Github](https://docs.gitbook.com/integrations/github)
[Github的GitBook项目](https://github.com/GitbookIO/gitbook/blob/master/docs/setup.md) [Github的GitBook项目](https://github.com/GitbookIO/gitbook/blob/master/docs/setup.md)
[github pages中文帮助](https://help.github.com/cn/github/working-with-github-pages/about-github-pages) [github pages中文帮助](https://help.github.com/cn/github/working-with-github-pages/about-github-pages)

Binary file not shown.

View File

@@ -0,0 +1,109 @@
标题别再把git当svn用了大厂程序员都是这样用git做版本管理的
## 版本控制
### 集中式
大家日常开发应该都有接触过版本控制,说起版本控制软件首先会想到老大哥`svn` 很多公司的老项目都会用svn来管理因为它是集中式的版本控制软件部署简单使用方便时svn的最大特点。我上家公司用的版本控制软件就是 `svn` ,包括鹅厂早起的项目也是基于 `svn` 做版本控制的,不过现在项目都是使用更加强大的 `git` 来做版本控制。
### 分布式
那么为什么需要版本控制呢?
## Git是什么
## 三种主流工作流
### Git flow
### Github flow
### Gitlab flow
## 实际操作
通用操作: git br -a 查看分支
开发分支操作:
// 1. 初始创建开发分支
git checkout -b dev/appeal_optimize_2 //创建并切换分支
git push -u origin dev/appeal_optimize_2 // 推送创建的分支到远端 (可选)
步骤2 可选
// 2.其他小伙伴下载代码后切换到开发分支
git clone
git checkout -b dev/appeal_optimize_2 origin/dev/appeal_optimize_2 // 创建本地开发分支并关联到远端分支
//3. 创建者已经在dev分支正常开发提交,推送到dev分支
git add file
git ci file -m 'msg'
git pull //拉取dev分支其他人的最新提交
git push // 推送到dev分支可选
// 4. 切换到master分支后把dev分支合并进来
git checkout master
git merge dev/appeal_optimize_2
//5. 开发完成删除dev分支必选包括本地和远程dev分支
git branch -d dev/appeal_optimize_2 // 删除本地分支
git push origin -d dev/appeal_optimize_2 或者 git push origin :dev/appeal_optimize_2 // 删除远程分支(可选)
出release版本流程操作 (非多人协作收集版本暂时可以不用这一步)
出release分支操作类似最后清除release分支
// 出完版本在master打tag做记录
git tag -a v2.0.0 -m "appeal optimize v2 region check and observe" master //本地
git push --tags 或者 git push origin v2.0.0 //远程
//版本出问题从master的tag处拉bugfix分支不影响其他开发分支
git checkout -b bugfix/appeal_optimize_2 v2.0.0
修改完合入master分支最后清除bugfix分支
## Reference
https://segmentfault.com/a/1190000016865867
https://iwiki.oa.tencent.com/pages/viewpage.action?pageId=103528756 主要参考 GitLab flow
http://km.oa.com/articles/show/349413?kmref=search&from_page=1&no=2 参考命令行 但是 他是Gitflow
http://km.oa.com/articles/show/429718?ts=1571801581 参考分支命名 但是他是Gitflow

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 95 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 109 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 174 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 138 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 111 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 216 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 295 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 117 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 111 KiB

BIN
images/公众号.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB