GitHub

A bi-directional GitHub integration

With GitBook you can synchronize your content with GitHub and keep your docs updated all the time!‌

The integration with GitHub is very easy to use: if you change your content on GitBook, your edits are pushed to a GitHub repository. Conversely, commits pushed to a GitHub repository are imported. ✨‌

Setup the GitHub integration

  1. From your space, click on the integrations tab > GitHub

  2. Authorize GitBook to access your GitHub account

  3. Select the repository that you want to connect

Panels in the integration tab 📦‌

Panels in the integration tab 📦

Once you completed, GitBook will add a webhook to your repository that will allow it to fetch content on every change to the repository. When making changes to GitBook, a new commit will be pushed.‌

That's it! ✨ You can continue editing from GitBook or your GitHub repository.‌

Setup with an empty repository

When configuring the GitHub integration with an empty repository, GitBook will push an initial commit with the content of your space.‌

Setup with an existing repository

When configuring the GitHub integration with an existing repository, you'll be prompted to choose which content to use (GitBook or GitHub).‌

  • When choosing GitHub, it'll replace your space's content with the repository's content

  • When choosing GitBook, it'll push your space's content to GitHub

Synchronizing branches

By default, GitBook only imports the master branch. During setup, other branches may be specified. Each new commit to these branches will be imported as a specific GitBook version:

You can use patterns to match branches. For example master docs/*, master, as well as all branches starting with docs/, will be imported as versions.

🧠 Tips: Drafts are not synced to GitHub, and Pull Requests on GitHub are not synced to GitBook. Only the current GitBook revision is exported to GitHub, following the branch mapping you defined.