> For the complete documentation index, see [llms.txt](https://docs.neohive.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.neohive.ai/add-your-context/repositories/sync.md).

# Keep a repository up to date

Set how often a Code or Documentation Index syncs, sync it on demand, and read the sync history.

A [Code](/reference/glossary.md#code-index) or [Documentation Index](/reference/glossary.md#documentation-index) stays up to date by syncing with its repository on a schedule. You choose the schedule, and you can click **Trigger sync** to index a change right away. When something looks wrong, **Sync history** shows what each sync did.

<figure><img src="https://3192197639-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4OPHduIiSuhnAhSI2yPb%2Fuploads%2Fgit-blob-31de1646745576e74361bf9b11c0390b59d232f2%2Fcontext-sync.svg?alt=media" alt="An example day in UTC with the default schedule. Scheduled syncs run every 4 hours at 00:00, 04:00, 08:00, and so on. At 10:12 you select Trigger sync, and a sync runs immediately. At 14:36 a CI pipeline calls the webhook after a merge and sends only the changed files. Only one sync runs per Index at a time."><figcaption></figcaption></figure>

Each sync reads only what changed since the last indexed commit. NeoHive indexes new, modified, and renamed files again, and removes deleted files from the [Index](/reference/glossary.md#index).

## Set the schedule

To set the schedule, do the following:

1. Open the Index's **Sync Settings** tab.
2. Under **Configuration**, select a **Sync interval**.
3. Click **Save settings**.

Syncs run at fixed times of day, in UTC. For example, **Every 4 hours** runs at 00:00, 04:00, 08:00, and so on, and **Daily** runs at 00:00.

If your machine is off or asleep when a sync is due, NeoHive runs the sync as soon as NeoHive starts again.

## Choose a sync interval

Pick the interval that matches how often the repository changes. The following table suggests an interval for each case:

| **Sync interval**                          | Good for                                                 |
| ------------------------------------------ | -------------------------------------------------------- |
| **Every 15 minutes**, **Every 30 minutes** | A busy repository where your agent needs changes quickly |
| **Every hour**                             | Most repositories                                        |
| **Every 4 hours**                          | The default for an Index you add from the dashboard      |
| **Daily**                                  | A repository that rarely changes                         |

## Sync now

To sync now, do the following:

1. At the top of the Index page, click **Trigger sync**.
2. If the **Sync Warning** dialog opens, click **I Understand**. The dialog says that the sync can slow down the machine.

To stop the dialog from opening each time, select **Don't show this again** before you click **I Understand**.

The page header shows the sync progress and a button to cancel the sync.

If some files fail to index, the rest of the repository still syncs, and NeoHive tries the failed files again on its own. If a file keeps failing, NeoHive leaves that file out until you click **Trigger sync**, and the Index page shows `Some files could not be indexed, the rest synced`. To find out why and fix it, see [Repository sync issues](/troubleshooting/sync.md).

To index changes right after every merge, your CI pipeline can send the changed files to the webhook refresh endpoint. The webhook works differently from a sync, as [How the webhook differs from a sync](/reference/webhooks.md#how-the-webhook-differs-from-a-sync) explains.

## Read the sync history

**Sync history** appears at the top of the **Sync Settings** tab and lists the newest run first.

| Column                   | Tells you                                                                                                                                               |
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Time**, **Duration**   | When the run started and how long it took                                                                                                               |
| **Status**               | `running`, `success`, `failed`, or `cancelled`. `partial`, shown in amber, means that some files failed                                                 |
| **Files**                | How many files changed, such as `+12A / ~3M / -1D / ↻2R`: **A** added, **M** modified, **D** deleted, **R** renamed. A type with no changes is left out |
| **Progress**, **Chunks** | Files done out of the total, and chunks added or removed                                                                                                |
| **Commit Range**         | The commits between the previous run and this one                                                                                                       |
| **Error**                | What went wrong. Select the error to read the full message                                                                                              |

For runs that keep failing, see [Repository sync issues](/troubleshooting/sync.md).

## If the branch is renamed

If someone renames the branch, for example from `master` to `main`, the sync usually follows the new name on its own. If it cannot, a banner on the Index page shows `A synced branch is no longer on the remote`, and everything indexed so far stays searchable. To sync the renamed branch, do one of the following:

* In the banner, under **Pick a branch to sync instead**, select the new branch, and then click **Sync this branch**.
* On the **Sync Settings** tab, select the new branch in **Branch**, and then click **Save settings**.

Either way, NeoHive starts a sync of the new branch.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.neohive.ai/add-your-context/repositories/sync.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
