# gitBook應用

安裝

```
npm install gitbook -g
```

## 使用gitbook init初始化書籍目錄&#x20;

README.md和Summary.md是兩個必須文件，README.md是對書籍的簡單介紹

```
gitbook init
Installing GitBook 3.2.3........

tree  /home/pi/mygithub/mynote/
/home/pi/mygithub/mynote/
├── README.md
└── SUMMARY.md

```

## gitbook服務

使用gitbook serve編譯書籍

```
gitbook serve
Live reload server started on port: 35729
Press CTRL+C to quit ...
........
........
Starting server ...
Serving book on http://localhost:4000

```

![](/files/-LwVeyzDuz3t4sc5uD3e)

## 建立書籍

```
gitbook build
```

```
git checkout --orphan gh-pages
git rm --cached -r .
rm -f *.md
echo "*~" > .gitignore
echo "_book" >> .gitignore

git commit -m "Ignore some files"
git checkout --orphan gh-pages
cp -r _book/* .
git add .
git commit -m "Publish book"
git config --global user.email "kawsing@gmail.com"
git config --global user.name "kawsing"
git remote add origin https://github.com/kawsing/mynote.git
git push -u origin gh-pages
```

![](/files/-LwVm5NcGMppXFrLVfNL)

## 變更內容

### nano SUMMARY.md

```
# MYSUMMARY

* [Chapter1](chapter1/README.md)
  * [Section1.1](chapter1/section1.1.md)
  * [Section1.2](chapter1/section1.2.md)
* [Chapter2](chapter2/README.md)

```

### gitbook build重新建立書籍

```
gitbook build
cp -r _book/* .
git add .
git commit -m "Publish Book"
git push -u origin gh-pages
```

<div align="left"><img src="/files/-LwW6HvIvU8i7Aj3xn_i" alt=""></div>

## 完整流程

```
mkdir Book
cd Book/
gitbook init
gitbook build
pi@ubuntu:~/mygithub/Book$ ls
_book  README.md  SUMMARY.md

pi@ubuntu:~/mygithub/Book$ git checkout --orphan gh-pages
fatal: not a git repository (or any of the parent directories): .git

pi@ubuntu:~/mygithub/Book$ ls -a
.  ..  _book  README.md  SUMMARY.md

pi@ubuntu:~/mygithub/Book$ git init
Initialized empty Git repository in /home/pi/mygithub/Book/.git/

pi@ubuntu:~/mygithub/Book$ git checkout --orphan gh-pages
Switched to a new branch 'gh-pages'
git rm --cached -r .

rm -rf *~

echo "*~" > .gitignore
echo "_book" >> .gitignore
git checkout --orphan gh-pages

git init
git commit -m "Ignore some files"
cp -r _book/* .

git add .

git commit -m "Publish book"
git push -u origin gh-pages
git remote add origin https://github.com/kawsing/Book.git
git commit -m "Publish book"
git push -u origin gh-pages

pi@ubuntu:~/mygithub/Book$ ls
_book  gitbook  index.html  README.md  search_index.json  SUMMARY.md

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://kawsing.gitbook.io/opensystem/github/github-ying-yong.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
