You can write a Leanpub book using Git and GitHub. In this section we'll show you how to create a book and generate your first preview.
Once you have successfully generated your first preview, you'll know everything you know to get started writing in the GitHub writing mode.
You'll find more information and detailed instructions on the "Getting Started" page for your book, which you'll go to automatically when you create your book.
Creating Your Book's GitHub Repository
The first thing you need to is create a repository for your book on GitHub.
To do this, go to https://github.com and sign in.
Click the green "New" button to the right of the list of Repositories.
This will take you to a page where you can set up a new repository for your Leanpub book.
By default, "Public" will be selected. This means anyone can see your repository. Select "Private" if you don't want anyone to be able to see your repository.
Next, type a name for your repository.
Click the green "Create repository" button.
This will take you to a "Quick setup" page:
Select the repository information and copy it.
Go to the command line on your computer. In this tutorial we're using a Mac, and we go to the command line by opening an application called "Terminal.'
Go to the folder on your computer where you want to clone your GitHub repository. In this tutorial, that is a folder called "repos."
Type "git clone" and paste in the repository information you copied on GitHub.
After a moment, you will see a message saying that the repository has been cloned.
Creating a Book in GitHub Writing Mode
Go to https://leanpub.com/create/book to create a book in GitHub writing mode.
First, type a title for your book into the "TITLE" box. You can change your title later.
Click in the "BOOK URL" box. Leanpub will automatically suggest a URL for your book's web page on Leanpub. You can change this URL at any time.
In this case, the URL that was automatically generated was already taken.
If a URL you want is already taken, you can add hyphens to create a URL that is close to it.
Scroll down and you will see "MAIN LANGUAGE USED IN YOUR BOOK." You can select a language from the drop-down. Like the other settings, you can change this at any time.
Scroll down and you will see the "BOOK THEME" options. "Business" will be selected by default. The Book Theme is just a set of standard formatting options conventional for books on these subjects. You are not required to choose any particular option. You can change your Book Theme at any time.
For this tutorial, we selected the "Fiction" Book Theme.
In the section below, you will be presented with various Writing Mode options. For this tutorial, select "Using Git and GitHub."
Scroll down and you will see a box to enter your GitHub username, followed by a forward slash / and your GitHub repo name.
Enter your GitHub username, followed by a forward slash / and your GitHub repo name.
When you scroll down further, you will see the subscription plan options. By default, "Free" will be selected. If you have a paid Leanpub account already, you will see that plan selected automatically.
Select a plan.
Scroll down and, if you are not signed in to a Leanpub account, you will see an option to enter information to create a new account. You will also see an option to sign in, if you already have a Leanpub account.
To create a new account, fill in the relevant information.
Tick the box to prove you're a person and click the blue button to finish creating your new GitHub book.
You will now see that you are on the Getting Started page for your book.
If you use bookmarks in your web browser, we recommend you bookmark this page in your web browser in a bookmark folder for your book, but this is not required.
Look at the Book Tools "breadcrumb" menu at the top of the screen. This is how you will navigate to the web pages you will be using in Leanpub to work on your book and see all the features we provide, like uploading a book cover, or setting a price for your book.
When you are finished this tutorial, we recommend you explore the various Book Tools options.
Adding Leanpub As A Collaborator on Your Book's GitHub Repository
Go back to the GitHub page for your book's GitHub repository.
Click on "Settings" near the top right, to go to the "Settings" page for the repository.
Click on "Collaborators" in the menu on the left, to go to the "Collaborators" page for the repository.
Type "Leanpub" in the search box.
Select the "Leanpub" option and click the "Add collaborator" button.
You will see that Leanpub has been added as a collaborator on the repository.
Adding Default Content to Your GitHub Repository
Next, you need to add some content to your GitHub repository. (Leanpub does not write to your GitHub repository.)
Go back to the Getting Started page for your book.
Scroll down to Step 2 and click the this zip file link, or click the link in this sentence in the tutorial. This will download the default content to your computer.
You will now find the file wherever you store downloads on your computer.
Double-click the folder to unzip it.
Copy the "manuscript" folder. Then, go to the cloned GitHub repository on your computer, and paste the "manuscript" folder into the repository.
Go back to the command line on your computer and change to the GitHub repository for your book.
git add . to the content using Git.
git commit -m "adding default manuscript folder". You will see messages indicating that the content has been committed.
Type `git push` to push the commit to the repository on GitHub.
Creating a Preview
To create your first preview, using the default content we included in your new book, go back the Getting Started page for your book:
Click on "Getting Started" at the top, and you will see your the Book Tools menu. It will look something like this:
Click on "Preview or Publish" under the "Book Info" column, and you will see something like this:
Select "Preview' in the column to the right, and you will go to the "Preview" page for your book:
Click the "Create Preview" button. You will go to a page like this, where you will see a progress bar at the top:
When the preview process is complete, you will see download links for the preview, in a variety of formats:
Click on the links to see what your book looks like in the various formats.
Next, we recommend you read the Getting Started page for your book. You've already done all the setting up - all that's left is for you to learn how to write in your book, which should only take a few more minutes!
In the menu on Leanpub, you can find the Getting Started page for your in your Book Tools menu at:
`Author > Books > [Your Book Title] > Book Info > Getting Started`
If you have any questions or can't find anything, please search our Help Center for authors here: [http://help.leanpub.com/author-help](http://help.leanpub.com/author-help).