gritHEAD → docs/init
Commands / Getting startedMarkdown

grit init

Create a new, empty repository.

grit init [-b|--initial-branch <name>] [--bare] [--object-format sha1|sha256]
[--ref-format <files|reftable>] [--separate-git-dir <dir>] [<path>]

Description

Creates an empty Git repository at <path>, or in the current directory when no path is given. The directory is created if it doesn't exist. A normal repository keeps its data in a .git directory next to your files. A bare repository has no working tree; the repository data is the directory itself, which is what you want for a repository that other people push to.

The first branch defaults to main, or to init.defaultBranch from your global Git config when you omit -b. It has no commits until you make one.

Use --ref-format reftable to initialize with Git's reftable ref backend (requires a reftable-capable Git for interoperability). The default is files (loose refs under refs/).

Use --object-format sha256 for a SHA-256 object database (Git repository format version 1 with extensions.objectformat = sha256). The default is sha1.

Use --separate-git-dir to keep the git directory outside the work tree (a gitdir: gitfile in .git points at the real directory).

Options

Option Description
<path> Where to create the repository. Defaults to the current directory.
-b, --initial-branch Initial branch name (overrides init.defaultBranch).
--bare Create a bare repository, with no working tree.
--object-format Object hash algorithm: sha1 (default) or sha256.
--ref-format Ref storage backend: files (default) or reftable.
--separate-git-dir Place the git directory at this path instead of <path>/.git.

JSON output

Schema: v1

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

Field Type Meaning
initialized boolean true when a new repository was created.
reinitialized boolean true when an existing repository was reinitialized in place (omitted when false).
path string Repository directory (the .git directory for a normal repository).
bare boolean Whether the repository is bare.
branch string Initial branch name (actual HEAD branch after reinit).
object_format string Object hash algorithm (sha1 or sha256).
ref_format string Ref storage backend (files or reftable).
git_dir string Separate git directory when --separate-git-dir was used (omitted when co-located).

Markdown output

Exit status

Code Meaning
0 Success (success).
1 Command failed (failure).
2 Invalid flags or arguments (usage).

See Exit codes for shared rules and structured --json kind values.