---
title: "checkout"
description: "Fetch sources and export their documents as plain files."
canonical_url: "https://diglot.sh/workflow/cli/checkout"
---
# checkout

> Fetch sources and export their documents as plain files.

`diglot checkout` makes sure each source has a local checkout, fetches its ref, and exports the documents the source yields to plain files under `.diglot/sources/<source>`. The exported files are the same ones `extract` reads, which makes them useful for tools that need the documents on disk, such as the [x18n plugin](https://diglot.sh/review-ui/overview).

```bash
pnpm dlx @diglot/cli checkout [sources...]
```

Name sources to export only those. Without names, every source in `sources.yml` is exported. Naming a source that doesn't exist is an error that lists the configured ones.

## What it does

1. If the source's `path` doesn't exist, creates a bare repository there and adds the clone URL `https://github.com/<repo>.git` as `origin`. This needs `repo` on the source.
2. Fetches the refs of every source that shares the checkout, one commit deep.
3. Reads the documents matched by `dir`, `include` and `exclude` at the source's `ref`.
4. Writes them to a temporary directory next to the target, then swaps it in place of the previous export, so an interrupted run doesn't leave a half-written export.

A checkout that is a normal working copy with a `.git` directory is left as it is and isn't fetched.

## Output

The command prints one line per source with the commit it exported, or the path when the source isn't a git repository:

```text
nuxt-main: <commit>
```

## Options

<table>
<thead>
  <tr>
    <th>
      Option
    </th>
    
    <th>
      Default
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        --cwd
      </code>
    </td>
    
    <td>
      <code>
        .
      </code>
    </td>
    
    <td>
      The translations repository root
    </td>
  </tr>
</tbody>
</table>


## Sitemap

See the full [sitemap](https://diglot.sh/sitemap.md) for all pages.
