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

# Connect a project to Git

> Initialize a Git repository inside an existing local project, or clone a repository into a new local project, from the Requestly desktop app.

There are two ways to put a local project under version control. Initialize a repository inside a project you already have, or clone an existing repository into a new project. Both start in the desktop app, and neither needs a terminal.

<Info>
  Git requires the **desktop app**. [Download Requestly](https://requestly.com/downloads).
</Info>

## Prerequisites

* A [local project](/collaboration/local-workspace). The **Git** tab does not appear while a team project is active.
* The `git` command installed on your machine.

## Initialize an existing local project

Use this path when the project already holds the collections you want to track.

<Steps>
  <Step title="Open the Git tab">
    Open the local project, then click **Git** in the API Client sidebar.
  </Step>

  <Step title="Initialize the repository">
    The panel shows the **No git repo** empty state, described as "Version-control your collections, environments, and requests." Click **Initialize git**.

    Requestly creates the repository in the project folder and names the first branch `main`.

    <Frame>
      <img src="https://mintcdn.com/requestly/eF9SdqtaJHfrCNE2/images/git-panel-no-repo.light.png?fit=max&auto=format&n=eF9SdqtaJHfrCNE2&q=85&s=b4a7423edee55d31e291766dc9a09780" alt="The Git panel before a repository exists, showing the No git repo empty state with an Initialize git button above the Commits, Stashes, Remotes, and Sync rows" className="dark:hidden" width="1280" height="800" data-path="images/git-panel-no-repo.light.png" />

      <img src="https://mintcdn.com/requestly/eF9SdqtaJHfrCNE2/images/git-panel-no-repo.dark.png?fit=max&auto=format&n=eF9SdqtaJHfrCNE2&q=85&s=713afd2268320ea100e5d5728177f40d" alt="The Git panel before a repository exists, showing the No git repo empty state with an Initialize git button above the Commits, Stashes, Remotes, and Sync rows" className="hidden dark:block" width="1280" height="800" data-path="images/git-panel-no-repo.dark.png" />
    </Frame>
  </Step>

  <Step title="Make the first commit">
    The panel switches to the change list, with every project file waiting under **Changes**. Stage what you want to track and write a commit. See [Stage and commit changes](/api-client/git/commit-changes).
  </Step>

  <Step title="Add a remote">
    A new repository has no remote yet, so the **Sync** section reads "Add a remote to push your commits." Click **Set a remote** to open the [Remotes tab](/api-client/git/remotes) and add one.
  </Step>
</Steps>

The **Sync** section and its **Set a remote** button are in the panel from the start, before any repository exists. Click the button before you initialize and the Remotes tab reads "Repository not initialized", so run the steps in order.

<Note>
  Requestly leaves an existing Git identity alone, and fills a missing one from a connected GitHub account. With no GitHub account connected Requestly sets nothing, so Git falls back to whatever identity your machine already has; if your machine has none, set one with `git config --global user.name` and `git config --global user.email`.
</Note>

## Clone a repository

Use this path when the collections already live in a repository, for example one a teammate pushed.

<Steps>
  <Step title="Open the project switcher">
    Click the project name at the top left of the app.
  </Step>

  <Step title="Start a new local project">
    In the **Local projects** section, click **Add project**. If you have no local projects yet, the section shows a **Create a local project** button instead. Either one opens the **Add a local project** dialog with three options.
  </Step>

  <Step title="Choose Clone from Git">
    Select **Clone from Git**, described as "Clone a GitHub, GitLab, or URL repository into a new local project." Then click the **Clone from Git** button.

    <Frame>
      <img src="https://mintcdn.com/requestly/K-Ztz5uJVTElPvBt/images/git-add-local-project-clone-option.light.png?fit=max&auto=format&n=K-Ztz5uJVTElPvBt&q=85&s=e3161f44972f3b0911aecee06fe350f1" alt="The Add a local project dialog with three options, Clone from Git selected, and Cancel and Clone from Git buttons" className="dark:hidden" width="1280" height="800" data-path="images/git-add-local-project-clone-option.light.png" />

      <img src="https://mintcdn.com/requestly/K-Ztz5uJVTElPvBt/images/git-add-local-project-clone-option.dark.png?fit=max&auto=format&n=K-Ztz5uJVTElPvBt&q=85&s=57a95d41e4c39f6ad18e1a3278dea355" alt="The Add a local project dialog with three options, Clone from Git selected, and Cancel and Clone from Git buttons" className="hidden dark:block" width="1280" height="800" data-path="images/git-add-local-project-clone-option.dark.png" />
    </Frame>
  </Step>

  <Step title="Enter the repository URL">
    On the **Paste URL** tab, pick **HTTPS** or **SSH** and paste the repository URL. The toggle is guidance only, and the field accepts either kind.

    * **HTTPS**: Requestly injects the saved credential for that host. If none is saved, it asks you to [connect the account](/api-client/git/providers-and-authentication).
    * **SSH**: Git uses your own system SSH keys, so Requestly needs no credential.

    A URL that is neither raises "Invalid Git remote URL. Use an HTTPS or SSH URL." under the field.

    <Frame>
      <img src="https://mintcdn.com/requestly/K-Ztz5uJVTElPvBt/images/git-clone-paste-url.light.png?fit=max&auto=format&n=K-Ztz5uJVTElPvBt&q=85&s=9a7a1371a20134b41faa01ed83573f07" alt="The Clone from Git dialog on the Paste URL tab, with an HTTPS repository URL, a chosen destination folder, and Back and Clone buttons" className="dark:hidden" width="1280" height="800" data-path="images/git-clone-paste-url.light.png" />

      <img src="https://mintcdn.com/requestly/K-Ztz5uJVTElPvBt/images/git-clone-paste-url.dark.png?fit=max&auto=format&n=K-Ztz5uJVTElPvBt&q=85&s=5f487c0c3755d782f524702a1ce87a5f" alt="The Clone from Git dialog on the Paste URL tab, with an HTTPS repository URL, a chosen destination folder, and Back and Clone buttons" className="hidden dark:block" width="1280" height="800" data-path="images/git-clone-paste-url.dark.png" />
    </Frame>
  </Step>

  <Step title="Choose the destination folder">
    The second field is empty, with **Destination folder** as its placeholder text rather than a label above it. Click **Choose…** beside it and pick a folder in the system dialog. The placeholder gives way to the path you picked. Requestly never fills this in for you.
  </Step>

  <Step title="Clone">
    Click **Clone**. The dialog shows **Cloning…** while Git runs. Do not close the dialog during a clone.
  </Step>
</Steps>

You can also browse the repositories of a GitHub or GitLab account instead of pasting a URL. Each provider adds its own tab to the same dialog, **Browse my GitHub repos** and **Browse my GitLab repos**. Picking a repository fills the URL field for you, and you still choose the destination folder. A tab whose account is not connected yet offers to connect it there and then. See [Providers and authentication](/api-client/git/providers-and-authentication).

### What happens after a clone

Requestly looks for a Requestly project inside the repository it just cloned.

| What Requestly finds                             | What happens                                                             |
| ------------------------------------------------ | ------------------------------------------------------------------------ |
| A `__requestly.json` file at the repository root | Requestly registers that folder as a project and opens it.               |
| A `__requestly.json` file in a subfolder         | Requestly registers the shallowest matching subfolder and opens it.      |
| No `__requestly.json` anywhere                   | Requestly keeps the cloned files and offers to set up a project in them. |

In the last case the dialog keeps its **Clone from Git** title and swaps its body for a panel headed "This repository isn’t a Requestly project yet". Click **Create new project here** and name the project. Requestly scaffolds it inside the cloned folder, and Git stays bound to the repository you cloned, so the remote, push, and pull keep working. Click **Cancel** to leave the files on disk and register nothing.

<Frame>
  <img src="https://mintcdn.com/requestly/K-Ztz5uJVTElPvBt/images/git-clone-no-project.light.png?fit=max&auto=format&n=K-Ztz5uJVTElPvBt&q=85&s=3d5f6d6e3d725c30a3f80352476835f4" alt="The Clone from Git dialog reporting that the cloned repository is not a Requestly project yet, showing the cloned folder path with Cancel and Create new project here buttons" className="dark:hidden" width="1280" height="800" data-path="images/git-clone-no-project.light.png" />

  <img src="https://mintcdn.com/requestly/K-Ztz5uJVTElPvBt/images/git-clone-no-project.dark.png?fit=max&auto=format&n=K-Ztz5uJVTElPvBt&q=85&s=5515c082ff9cad15565eea79e82cfb44" alt="The Clone from Git dialog reporting that the cloned repository is not a Requestly project yet, showing the cloned folder path with Cancel and Create new project here buttons" className="hidden dark:block" width="1280" height="800" data-path="images/git-clone-no-project.dark.png" />
</Frame>

## Next steps

<CardGroup cols={2}>
  <Card title="Stage and commit changes" icon="code-commit" href="/api-client/git/commit-changes">
    Read the change list, stage or discard files, and write a commit.
  </Card>

  <Card title="Push and pull" icon="arrows-rotate" href="/api-client/git/push-and-pull">
    Fetch from the remote, read the ahead and behind counts, and sync your work.
  </Card>
</CardGroup>
