# Keeping book source in GitHub

## This section needs rewrite - do not use it while this warning is here

## GitBook books living in GitHub

This document is a part of Aurelia-Tools internal documentation library. It describes the **process of its own creation** using only the browser to do it.

#### If you already have a book in GitBook repository and want to transfer it to GitHub, start reading at section 2. below.

### 1. Create a new book

Point your browser to our GitBook main page: <https://www.gitbook.com/@aurelia-ui-toolkits> and click on the `+ NEW` button (Image 1, below)

![](https://cloud.githubusercontent.com/assets/2712405/19396694/4cc8fdce-9212-11e6-8382-0f3da5d9f68e.png)

\
\
&#x20;Image 1

This should result with the `Create a new book` dialog: (Image 2 below). Define your choices in the order suggested by red markers.

![](https://cloud.githubusercontent.com/assets/2712405/19396808/db182622-9212-11e6-94f2-298daca8f74d.png)

\
\
&#x20;Image 2

I also deleted the "Chapter 1" page that is a part of the template selected with the click on item tagged with red marker 1 on the Image 2 above. For this document, a single page is sufficient.

Now, our book is created and can be accessed via URL <https://aurelia-ui-toolkits.gitbooks.io/gitbooks-living-in-github/details> and as the URL suggests, it is persisted on the `gitbooks.io` server - not in GitHub.

### 2. Transfer the book to GitHub

#### Summary of actions

The summary of actions described [How can I transfer my content to GitHub?](https://help.gitbook.com/github/how-can-i-export-to-repo.html) - section `Using the command line` is:

* create the new repository in GitHub that should have the same or similar name to your current repository on GitBook, created as the consequence of the action in step `1. Create a new book` above.
* get the `git` url of your GitBook book repository which is typically defined as `https://git.gitbook.com/MyName/MyBook.git`
* -clone this book to your machine
* push this local clone to the newly created GitHub based repository (with the intent to ovewrite that destination.

#### 2.1 Open the book

Point your browser to <https://aurelia-ui-toolkits.gitbooks.io/gitbooks-living-in-github/details> and click on the `SETTINGS` link (Image 3 below)

![](https://cloud.githubusercontent.com/assets/2712405/19400465/562aef14-9224-11e6-859b-c5deb50de2de.png)

\
\
&#x20;Image 3

#### 2.2 Create the empty repository on Github (new home for your book)

This is the critical step that is not well explained in the existing documentation.

![](https://cloud.githubusercontent.com/assets/2712405/19402678/6092d848-9230-11e6-96aa-cbd239860b31.png)

\
\
&#x20;Image 4

Click on `Create repository` buttom (marker 5, Image 4) results with the new GitHub repo with the URL `https://github.com/aurelia-ui-toolkits/GitBook-books-living-in-GitHub`

#### 2.3 Clone the original book to the local computer

This is simply done as:

```
C:\work\tests
λ git clone https://git.gitbook.com/aurelia-ui-toolkits/gitbooks-living-in-github.git
Cloning into 'gitbooks-living-in-github'...
remote: Counting objects: 47, done.
remote: Compressing objects: 100% (45/45), done.
remote: Total 47 (delta 12), reused 5 (delta 0)
Unpacking objects: 100% (47/47), done.
Checking connectivity... done.
```

#### 2.4 Push this local book clone to GitHub

Again, using your console, you need to do your equivalent of this

```
λ cd gitbooks-living-in-github

C:\work\tests\gitbooks-living-in-github (master)
λ git push https://github.com/aurelia-ui-toolkits/GitBook-books-living-in-GitHub master --force
Counting objects: 47, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (45/45), done.
Writing objects: 100% (47/47), 6.32 KiB | 0 bytes/s, done.
Total 47 (delta 12), reused 0 (delta 0)
remote: Resolving deltas: 100% (12/12), done.
To https://github.com/aurelia-ui-toolkits/GitBook-books-living-in-GitHub
 + 818e464...af55099 master -> master (forced update)

C:\work\tests\gitbooks-living-in-github (master)
```

### 3. Set GitBook editor to manage your new copy in GitHub

Point the browser to `https://github.com/aurelia-ui-toolkits/GitBook-books-living-in-GitHub` and observe:

![](https://cloud.githubusercontent.com/assets/2712405/19403361/c531f992-9234-11e6-8a06-4787426daca4.png)

\
\
&#x20;Image 5

In order to associate the [**GitBook web editor**](https://www.gitbook.com/blog/releases/webeditor) with your book stored in GitHub, click on the `Settings` link (Image 5, marker 1). This will result with

![](https://cloud.githubusercontent.com/assets/2712405/19403501/caee9790-9235-11e6-80db-ee88e193b6ae.png)

\
\
&#x20;Image 6

Click on the `Browse directory` icon (Image 6, marker 1) will bring the list of all GitHub integrations. Scroll down until you see the GitBook icon

![](https://cloud.githubusercontent.com/assets/2712405/19403574/26103a98-9236-11e6-98da-3befbcec326f.png)

\
\
&#x20;Image 7

Click on the GitBook icon establishes the needed relationship, where your book is stored in GitHub, can be edited by GitBook web editor and will be hosted (as a web site) at GitBook.

![](https://cloud.githubusercontent.com/assets/2712405/19403700/ef007e54-9236-11e6-9b19-23a3cd639ff9.png)

\
\
&#x20;Image 8


---

# 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://aurelia-ui-toolkits-1.gitbook.io/how-to-create-a-book/keeping-book-source-in-github.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.
