gritHEAD → docs/clone
Commands / Getting startedMarkdown

grit clone

Copy a remote repository into a new directory.

grit clone <url> [<dir>]

Description

Copies the repository at <url> into a new directory and checks out the remote's default branch. The remote is saved as origin, so grit fetch, grit pull and grit push work with no further setup.

<url> can be an https:// or http:// URL, an ssh:// URL or user@host:path address, a git:// URL, a file:// URL, a path to a local repository, or a path to a git bundle file (recognized by its header signature). A local path is stored as an absolute path so that later fetches work from anywhere.

Without <dir>, the directory is named after the last part of the URL with any .git suffix removed, so https://github.com/gitbutlerapp/grit.git clones into grit. The destination must not exist or must be empty.

For private GitHub repositories over HTTPS, sign in first with grit auth.

You can clone from a shallow repository (including one created with git clone --depth); grit copies the shallow boundary into the new repository so history matches the source.

Options

Option Description
<url> The repository to clone: a URL or a local path.
<dir> The directory to clone into. Defaults to the repository's name.

JSON output

Pass --json for stable, scripting-friendly output:

Field Type Meaning
url string The URL or path that was cloned.
path string Directory the clone was created in.
branch string Branch that was checked out.