# Install grit

> Install the grit CLI on your machine, try nightly builds, and keep your copy up to date.

## Stable release (recommended)

On macOS and Linux:

```bash
curl -fsSL https://grit-scm.com/install | sh
```

On Windows, run this in PowerShell:

```bash
irm https://grit-scm.com/install.ps1 | iex
```

The script downloads the latest release from GitHub, installs the `grit` binary (by default into `~/.local/bin` on Unix), and prints the version it installed.

## Linux GNU loader compatibility

Linux x86_64 releases provide two GNU assets. Both preserve PIE and ASLR:

| Asset | Loader support |
| --- | --- |
| `grit-x86_64-unknown-linux-gnu.tar.gz` | Default and fallback; glibc 2.34 or newer, standard relocations |
| `grit-x86_64-unknown-linux-gnu-relr.tar.gz` | Manual opt-in; glibc 2.36 or newer, packed relative relocations (RELR) |

The stable and nightly installers always choose the existing GNU asset on glibc
systems, including glibc 2.36 and newer. The RELR asset is available only as a
manual download for glibc 2.36+. Its smaller relocation metadata does not
consistently improve startup: final-tip review measurements found tiny commands
about **1–2% slower**, despite gains at earlier revisions. Automatic selection
is deferred until measurements on the release artifacts demonstrate a benefit;
see [benchmarks](https://grit-scm.com/docs/install/benchmarks.md/index.md#pie-startup-relocation-probe).

The default asset's weak glibc 2.39 references do not require a newer loader.
GNU aarch64, static musl, macOS and Windows keep their existing artifacts and
selection. Static musl artifacts and source builds remain alternatives for
other systems.

## Shell completions

Tab completion helps you discover `grit`'s subcommands and flags. Generate a script with [`grit completions`](https://grit-scm.com/docs/completions/index.md) and load it from your shell config, or copy the pre-generated files from a release tarball's `completions/` directory.

**bash** — add to `~/.bashrc`:

```bash
eval "$(grit completions bash)"
```

**zsh** — add to `~/.zshrc`:

```bash
eval "$(grit completions zsh)"
```

Or install once under a site-functions directory:

```bash
grit completions zsh > ~/.local/share/zsh/site-functions/_grit
```

**fish** — write a completion file:

```bash
mkdir -p ~/.config/fish/completions
grit completions fish > ~/.config/fish/completions/grit.fish
```

After [`grit update`](https://grit-scm.com/docs/update/index.md), regenerate completions so new commands appear.

## Nightly builds

CI publishes a rolling **nightly** prerelease when the release workflow is triggered manually. To install that build instead of the latest stable release:

```bash
curl -fsSL https://grit-scm.com/install-nightly | sh
```

On Windows:

```bash
irm https://grit-scm.com/install-nightly.ps1 | iex
```

Nightlies track recent `main`; use them when you want to test fixes before the next tagged release.

## Install with Cargo

If you already have a Rust toolchain:

```bash
cargo install grit-cli
```

This builds and installs the `grit` executable into Cargo's bin directory (usually `~/.cargo/bin`). Make sure that directory is on your `PATH`.

## Keep grit up to date

After a script install, run [`grit update`](https://grit-scm.com/docs/update/index.md) to re-run the same installer and replace the binary you're running. If you installed with Cargo, update with:

```bash
cargo install grit-cli
```

## Build from source

Clone [the repository](https://github.com/gitbutlerapp/grit) and build the CLI crate:

```bash
cargo build --release -p grit-cli
```

The binary is `target/release/grit`. You can copy it anywhere on your `PATH`, or run it from the build tree.

### Toolchain

**Contributors** building this repository: the workspace pins **1.99.0** in [`rust-toolchain.toml`](https://github.com/gitbutlerapp/grit/blob/main/rust-toolchain.toml) (with `rustfmt` and `clippy`). `rustup` picks that up automatically when you build in the repo.

**Library and CLI consumers** (your own crate depending on `grit-lib` or `grit-cli` from [crates.io](https://crates.io/crates/grit-lib), without this repo's `rust-toolchain.toml`): the published crates require **Rust 1.95** or newer. Cargo prints that requirement before compiling if your toolchain is too old.

To use `grit-lib` in your own project, see the [library quick start](https://grit-scm.com/docs/library-quickstart/index.md).
