For the complete documentation index, see llms.txt. This page is also available as Markdown.

Enabling GitHub Sync

Set up and authorize the GitHub integration for GitBook

Getting started

In the section you want to sync with your GitHub repo, click Set up next to Git Sync in the section header. From the provider list, click GitHub Sync.

A GitBook screenshot showing GitHub Sync configuration options
GitHub Sync configuration options.

Authenticate with GitHub

If you’re setting up GitHub Sync for the first time and haven’t already linked a GitHub account, you’ll be prompted to do that when you begin configuring Git Sync. If you’ve already linked your account, you may still need to authenticate via GitHub.

Install the GitBook app to your GitHub account

If you haven’t already done so, you’ll see a prompt to add the GitBook app to your GitHub account.

Follow the instructions in the GitHub popover and either give GitBook specific repository permissions, or allow access to all repositories, depending on your needs.

Select a repository and branch

Select the account and repository you want to keep in sync with your GitBook content.

Can’t see your repository? If you can't find your repository in the list, make sure that you've installed the GitBook GitHub app in the right scope (i.e. your personal account or the GitHub org where the repository lives). You should also check that you’ve configured the correct repository access in the GitBook GitHub app.

Once you’ve selected the correct repository, choose which branch you want commits to be pushed to and synced from.

Perform an initial sync

For the initial sync, the selected source is authoritative. The initial sync can replace existing content in its destination.

Choose one of these directions:

  1. GitBook → GitHub: GitBook is the source of truth. Use this direction only when the selected branch can receive your section’s content.

  2. GitHub → GitBook: The selected GitHub branch is the source of truth. Use this direction only when your section can receive that branch’s content.

When you’re ready, start the initial sync.

If you chose the wrong direction

Git Sync operations appear in the section’s Version history. Locate the revision immediately before the Git Sync operation, then click Rollback to restore the prior section content.

For detailed steps, see Version control.

Disconnecting Git Sync stops future synchronization. It does not restore content automatically.

If the pre-sync revision is unavailable or you can’t complete the rollback, contact GitBook Support.

Write and commit

You’re good to go. You’ll notice that if your section was in live edit mode, live edits are now locked. This allows us to reliably sync content to your repository when someone in your team merges a change request in GitBook.

When you edit on GitBook, every change request merge will result in a commit to your selected GitHub branch.

When you commit to GitHub, every commit will be synced to your GitBook section as a history commit.

Last updated

Was this helpful?

Powered by GitBook