--- name: ngit description: Provides commands and workflows for nostr:// git repositories using the ngit CLI and git-remote-nostr. Activates when working with nostr:// remotes or URLs, ngit commands, gitworkshop.dev repositories, submitting or reviewing pull requests (PRs) or patches over Nostr, creating or viewing Nostr git issues, cloning a nostr:// URL, publishing a repository with ngit init, or any task involving the ngit CLI or git-remote-nostr. license: CC-BY-SA-4.0 metadata: version: "1.0" --- # ngit — Nostr Plugin for Git ngit makes `clone`, `fetch`, `push` work with `nostr://` URLs and adds a CLI for PRs, issues, and repo management over the decentralised Nostr protocol. - Install: `curl -Ls https://ngit.dev/install.sh | bash` (installs `ngit` and `git-remote-nostr`) - Web UI: https://gitworkshop.dev ## Key rules - **Always use `--json`** on `ngit` commands when reading output — far easier to parse than human-readable text. `git` commands do not support `--json`. - **Use `--offline`** on all but the first `ngit` command in a session — reads from local cache instantly. `git fetch origin` also refreshes the cache. - **Never construct NIP-05 addresses** (`user@domain`). Use the `npub1...` form unless a NIP-05 address was explicitly provided. - **``** accepts a 64-char hex event ID or a `nevent1...` bech32 string. Get IDs from `ngit pr list --json` or `ngit issue list --json`. ## Detecting a nostr repo ```bash # Check if current directory is a nostr repo (always exits 0) ngit repo --json --offline | grep -q '"is_nostr_repo":true' ``` Returns full repo info (including `nostr_url`, `maintainers`, `grasp_servers`) when true. ## nostr:// URLs ``` nostr:/// nostr://// # relay-hint is bare domain, e.g. relay.ngit.dev ``` Standard git commands work directly with these URLs — `git-remote-nostr` resolves them transparently. ## Publishing a repo ```bash ngit init # interactive ngit init --name "My Project" --description "What it does" -d # non-interactive ngit repo edit --description "New description" # update metadata ngit repo --json --offline # view repo info (check nostr_url field) ``` ## Cloning ```bash git clone nostr://// # preferred git clone nostr:/// # slower discovery, no relay hint git clone nostr://user@domain.com/ # NIP-05, only if given to you ``` ## Pull Requests ### Open a PR ```bash git checkout -b pr/my-feature # ... commits ... git push -u origin pr/my-feature \ -o 'title=My feature title' \ -o 'description=Summary.\n\nDetail here.' ``` Push options `title=` and `description=` are required. Use `\n\n` for paragraph breaks. ### Advanced: ngit send ```bash ngit send HEAD~2 --title "My Feature" --description "Details" ngit send --defaults # non-interactive ngit send HEAD~2 --in-reply-to # update existing PR ``` ### List / view / comment ```bash ngit pr list --json ngit pr list --json --status open,draft,closed,applied ngit pr list --json --label bug ngit pr view --json ngit pr view --json --comments ngit pr comment --body "Looks good" ngit pr comment --body "Fixed!" --reply-to ``` ### Checkout / apply ```bash ngit pr checkout ngit pr apply ``` ### Merge (maintainer) ```bash ngit pr checkout git checkout main git merge pr/my-feature # or: git merge --squash pr/my-feature && git commit git push origin main # push to nostr remote records the merge event ``` ### Lifecycle ```bash ngit pr close ngit pr reopen ngit pr ready # mark draft as ready for review ``` ## Issues ```bash ngit issue create --title "Bug title" --body "Details" --label bug ngit issue create --title "Feature" --body "..." --label enhancement --label help-wanted ngit issue list --json ngit issue list --json --status closed ngit issue list --json --label bug ngit issue view --json ngit issue view --json --comments ngit issue comment --body "Reproduced on v2.1" ngit issue comment --body "Thanks!" --reply-to ngit issue close ngit issue reopen ``` ## Account management ```bash ngit account login # interactive, stores nsec in global git config ngit account login --bunker-url bunker://... # NIP-46 remote signer ngit account login --local # this repo only ngit account create --name "Alice" ngit account export-keys ngit account logout git config --global nostr.nsec # set directly ngit --nsec # inline for CI, no login needed ``` ## Sync ```bash ngit sync # sync all refs from nostr state to git servers ngit sync --ref-name main # sync specific ref ``` ## Key flags | Flag | Description | | --- | --- | | `-d`, `--defaults` | Non-interactive; use sensible defaults | | `--offline` | Local cache only, skip network | | `--json` | Structured output (ngit commands only) | | `-n`, `--nsec ` | Provide nsec or hex private key inline | | `-f`, `--force` | Bypass safety guards | | `-v`, `--verbose` | Verbose output | ## git config ```bash ngit --customize # show all options git config nostr.repo-relay-only true # don't broadcast to personal relays ```