Import or migrate your content to GitBook with Git Sync

Easily import content from you previous documentation provider — or from GitHub or GitLab — using Git Sync in GitBook

One of the best ways to import your content into GitBook is using Git Sync. With Git Sync, you can choose to import a repository from either GitHub or GitLab, to add all your docs content to your new GitBook organization in minutes.

Importing from GitHub

From your GitBook space, navigate to the top right of the screen and click Set up Git Sync. This will open a modal where you can configure the GitHub integration.

Before you go any further, you’ll need to install the GitBook app on GitHub.

If you haven’t done this already, 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.

To set up GitHub Sync, authorize GitBook with GitHub and select the account your content lives in.

Next, select the GitHub repository you want to sync with your GitBook space, and choose which branch you want commits to be pushed to and synced from.

In GitBook, select the repository and branch you want to sync, choose the direction of the initial sync, and GitBook will do the rest.

Finally, you can start your initial sync. When syncing for the first time, you’ll have the option to sync in one of two directions:

  1. GitHub -> GitBook will sync content from your selected branch with your GitBook space. This is great if you have existing Markdown content in a repository and want to import it into GitBook.

  2. GitBook -> GitHub will sync content from your GitBook space to the selected branch. This is great if you’re starting with an empty repository and want to get your GitBook content in quickly.

Connecting with GitLab

To set up GitLab sync, you’ll first need to create an access token — then you can follow the same process as GitHub Sync.

From your space, navigate to the top right of the screen and click Set up Git Sync. This will open a modal where you can configure the GitLab integration.

From here, you’ll need to enter a personal GitLab access token. You can create your access token in GitLab by navigating to Settings > Access Tokens

When configuring the tokens, you need to ensure that you enable the following access for your token:

  • api

  • read_repository

  • write_repository

Once you have generated the token, paste it into the text field in GitBook and click Authenticate.

Next, select the GitLab repository and branch you want to keep in sync with your GitBook content.

Finally, you can start your initial sync. When syncing for the first time, you’ll have the option to sync in one of two directions:

  1. GitLab -> GitBook will sync content from your selected branch with your GitBook space. This is great if you have existing Markdown content in a repository and want to import it into GitBook.

  2. GitBook -> GitLab will sync content from your GitBook space to the selected branch. This is great if you’re starting with an empty repository and want to get your GitBook content in quickly.

Once you have synced your content using Git Sync, the sync runs both ways. That means any changes you or your team make in your GitHub or GitLab repository will be reflected in GitBook, and vice versa.


→ How to find & replace or batch change with Git Sync

→ Discover more about Git Sync on our website

→ Read the GitSync documentation

Last updated

Was this helpful?