> ## Documentation Index
> Fetch the complete documentation index at: https://docs.diversion.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Import from Git

> How to get an existing repo from Git into Diversion

export const Image = ({src, alt}) => <img src={src} alt={alt} style={{
  width: '90%',
  borderRadius: '1.5rem',
  border: '.3rem solid #555',
  boxShadow: '0 0 1rem #888'
}} />;

Importing an existing repo from Git can get you quickly up and running with Diversion.
You can also enable bi-directional sync between your Git repo and Diversion, so that
changes made in either place are reflected in the other.
This is a great way to take Diversion for a test drive with no commitment.

<Tabs>
  <Tab title="Web UI">
    To import a repo using the Web UI, follow these steps:

    <Steps>
      <Step title="Enable Diversion Sync">
        Go to the [Diversion Sync GitHub App page](https://github.com/apps/diversion-sync) and follow the instructions to install it.
      </Step>

      <Step title="Open the repo selector and choose 'Import Git repository'">
        Go to [your Dashboard](https://app.diversion.dev/dashboard), open the repo selector dropdown (top-left), and choose **Import Git repository** from its footer (alongside **Create new repository** and **Import from Perforce**).

        <img src="https://mintcdn.com/diversion-2/cRpeD_gsb0j32D_2/images/import-repo-button.jpg?fit=max&auto=format&n=cRpeD_gsb0j32D_2&q=85&s=1d4cb2ef1b24a6ae677f3eafc44e5285" alt="Import repo button" style={{width: '90%', borderRadius: '1.5rem', border: '.3rem solid #555', boxShadow: '0 0 1rem #888' }} width="287" height="425" data-path="images/import-repo-button.jpg" />
      </Step>

      <Step title="You'll be prompted to choose your import options">
        <img src="https://mintcdn.com/diversion-2/tNxAwm8NrThaCp35/images/import-repo-options.jpg?fit=max&auto=format&n=tNxAwm8NrThaCp35&q=85&s=9f9c914d01c192243631b90e5d68a44a" alt="Import repo options modal" style={{width: '90%', borderRadius: '1.5rem', border: '.3rem solid #555', boxShadow: '0 0 1rem #888' }} width="576" height="602" data-path="images/import-repo-options.jpg" />

        Choose whether you want to import your entire repo and keep all of its history, or just the latest commit from a specific branch.

        If you choose to `Import all branches with history`, you'll have the option to `Enable continuous bi-directional sync`.

        <Card title="Note" icon="circle-info" iconType="duotone" color="#ca8b04">
          If you need bi-directional sync, please contact us at [support@diversion.dev](mailto:support@diversion.dev).
        </Card>
      </Step>

      <Step title="Enter the url for the repo you want to import" />

      <Steps title="Click the 'Import' button" />

      <Step title="Wait for the import to complete">
        This happens in the background, and depending on the size of your Git repo can take a few minutes.
        You will receive an email when the import is complete.
      </Step>
    </Steps>
  </Tab>

  <Tab title="CLI">
    To import a repo using the CLI, follow these steps:

    <Steps>
      <Step title="Enable Diversion Sync">
        Go to the [Diversion Sync GitHub App page](https://github.com/apps/diversion-sync) and follow the instructions to install it.
      </Step>

      <Step title="Open a CLI terminal">
        Open your terminal of choice.

        <Card title="Using the Diversion Interactive Shell" icon="lightbulb" iconType="duotone" color="#ca8b04">
          If you want an interactive shell with nicer UI, open your terminal of choice and run the `dv` command.
          It works the same as your regular terminal, and you can use any of the `dv` commands (`commit`, `init`, etc...) directly without prefacing them with `dv`.
        </Card>
      </Step>

      <Step title="Import">
        Run the following command:

        ```bash theme={null}
          dv import [git_url]
        ```

        This will start importing your repo into Diversion with the default name - the same as the repo's name in Git.

        There are several optional arguments for the `import` command. You can always run `dv help import` to see them in the terminal.

        <AccordionGroup>
          <Accordion title="[repo-name]">
            Passing a repo name to the `import command` will save the repo to Diversion with that name, instead of the repo's name in Git.

            ```bash theme={null}
              dv import [git_url] [repo-name]
            ```
          </Accordion>

          <Accordion title="--with-sync">
            Enables bi-directional sync between your new Diverson repo and your Git repo. This means that any change you make to one repo will be reflected in the other.

            This is useful for testing Diversion or for keeping any Git-based pipelines you have in place.

            ```bash theme={null}
              dv import [git_url] --with-sync
            ```

            <Card title="Note" icon="circle-info" iconType="duotone" color="#ca8b04">
              If you need bi-directional sync, please contact us at [support@diversion.dev](mailto:support@diversion.dev).
            </Card>
          </Accordion>

          <Accordion title="--git-branch">
            By default, Diversion will import the latest commit from the default branch of your Git repo. If you want to import the latest commit from a different branch, you can use the `--git-branch` flag.

            ```bash theme={null}
              dv import [git_url] --git-branch [branch-name]
            ```
          </Accordion>

          <Accordion title="--with-history">
            By default, Diversion will only import the latest commit from the default branch of your Git repo. If you want to import the entire repo with all of its history, you can use the `--with-history` flag.

            ```bash theme={null}
              dv import [git_url] --with-history
            ```
          </Accordion>
        </AccordionGroup>
      </Step>

      <Step title="Wait for the import to complete">
        This happens in the background, and depending on the size of your Git repo can take a few minutes.
        You will receive an email when the import is complete.
      </Step>
    </Steps>
  </Tab>
</Tabs>
