git-nostr.dev

module
v0.0.0-...-924f9ce Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 29, 2026 License: ISC

README

Git Nostr Tools

Git commands for working with repositories and pull requests using NIP-34.

Repositories can be hosted on any Git server. Nostr is used for repository identity, discovery, and communicating changes.

Installation

Install Git and Go, then run:

go install git-nostr.dev/cmd/...@latest

Put Go's binary directory on PATH. It is $GOBIN when set and otherwise defaults to $(go env GOPATH)/bin. Git finds both git nostr and the git-remote-nostr helper there.

Shell completion

To enable completion in Fish, run:

git nostr completion fish | source

Add this line to your Fish config to load it in new sessions. For other shells, run git nostr completion -h.

Nostr setup

Configure at least one relay you use for Git collaboration. Repeat the command to add more relays.

git config --global --add nostr.relay wss://relay.example.org

Set NOSTR_SECRET_KEY in your environment for commands that sign events. It accepts an nsec, a hex secret key, an encrypted ncryptsec, or a bunker URL. You can clone and fetch without setting a signing key.

Commands

Command Description
git nostr login <host> Sign in to a repository host
git nostr create <repository-id> [directory] Create a local and remote repository
git nostr init <repository-id> Announce an existing repository and switch origin to its Nostr URL
git nostr set-push-url <url> Set the push destination for a checkout with a Nostr origin
git nostr announce Edit and republish the announcement for origin
git nostr fork [repository-id] Create a personal fork of the current repository
git nostr pr open [destination] Create a pull request from the current branch
git nostr pr checkout <nevent> Check out a pull request in a new local branch
git nostr pr update Publish the current branch tip as a PR revision
git nostr send-patch Publish commits as a patch series
git nostr am <nevent> Fetch and apply a patch or patch series

Run git nostr -h for the command list or git nostr pr checkout -h for help with a specific command. To use a shorter spelling, configure a Git alias:

git config --global alias.pr 'nostr pr'

The git-remote-nostr helper supports Nostr repository URLs in ordinary Git commands.

Repository creation

Hosting setup

Sign in to your hosting account and set your default host. Follow the prompts to authorize Git Nostr in your browser. For example:

git nostr login github
git config --global nostr.hosting github

git nostr create and git nostr fork create public repositories under the signed-in account. Git pushes use your existing Git credentials, so make sure Git can push to your host over HTTPS.

Use --hosting <host> to select a host for one command.

git nostr create project --hosting github
git nostr fork my-fork --hosting github
Creating a repository
git nostr create project

This creates a directory named project, initializes a Git repository, provisions a remote repository, publishes an announcement, and configures origin.

An optional second argument specifies the local directory:

git nostr create project ~/source/project

The new repository has no upstream.

Choose a <repository-id> for the repository's Nostr URL. The display name defaults to this ID and can be edited later without changing the URL.

Plain git nostr create is noninteractive. Use --interactive (-i) to open the metadata editor before creating the repository.

git nostr create project --interactive
git nostr create project ~/source/project -i
Forking a repository
git clone https://github.com/owner/project.git
cd project
git nostr fork my-fork

Supply a repository ID when forking an ordinary Git repository. Its fetch URL must use HTTPS without embedded credentials, a query string, or a fragment. When forking a Nostr repository, you can omit the ID to use the source ID.

This creates a standalone repository on the selected host and pushes the upstream default branch at its advertised tip. That branch becomes the fork’s default. Publish any other branches or tags with ordinary Git pushes.

The command announces the fork, sets origin to the fork's Nostr URL, and keeps the source URL as upstream.

Existing local branches and refs are preserved. Use git nostr fork -i to edit the metadata for a new or existing fork before publishing.

Using Nostr for an existing repository

Run git nostr init from a checkout whose origin fetch URLs all use HTTPS without embedded credentials, query strings, or fragments. You can keep a separate SSH push URL.

git nostr init project
# Or edit the metadata before publishing the first announcement.
git nostr init project -i

The command requires a <repository-id> and runs noninteractively by default. Use --interactive (-i) to open the metadata editor.

The command announces the existing fetch URLs and changes origin to its nostr:// URL. Continue to use git fetch origin and git push origin. Your Git server still hosts the repository, and your push preference carries over in the current checkout.

After cloning on another machine, you can set a separate push URL for that checkout:

git nostr set-push-url git@github.com:owner/project.git

This changes local Git configuration only. You still need the repository owner's Nostr signing key and write access to the Git host to push. If you use a custom Git remote helper, set protocol.<name>.allow to always in your Git configuration for that protocol.

Repository metadata

git nostr announce

git nostr announce opens a TOML editor for the repository at origin. Edit the display name, description, website URLs, clone URLs, or hashtags. Git tries the clone URLs in the order you list them. Saving changes republishes the announcement at the same Nostr URL. The command is silent on success.

Nostr remotes

The git-remote-nostr helper resolves repository identities to their Git hosting endpoints. To share a repository by its owner's NIP-05 name, use nostr://<nip05>/<identifier>.

git clone nostr://<nip05>/<identifier>
git fetch origin
git push origin feature

The origin remote retains its Nostr URL even when Git objects are hosted on SSH, GitHub, or another Git server.

When cloning a fork, the helper reads the upstream relationship from the announcement and configures the upstream remote.

A fork checkout can use URLs such as:

origin    nostr://alice@example.com/project
upstream  nostr://bob@example.org/project

Pushing updates the Git repository and publishes repository-state events.

Pull requests

A pull request is created explicitly:

git switch -c feature
git commit -am "Implement feature"
git push -u origin feature

git nostr pr

By default, git nostr pr targets the repository configured as upstream. A different destination can be supplied:

git nostr pr open upstream
git nostr pr open another-remote
git nostr pr open nostr://<nip05>/<identifier>

The destination must resolve to a repository announcement.

Updating a pull request

Opening or checking out a PR associates it with a local branch.

Subsequent pushes of that branch automatically publish PR updates:

git commit -am "Address review comments"
git push

The remote helper publishes an update after the Git push succeeds, provided the Nostr signer is authorized to update the PR.

If the current commit is already available at your Git host and you only need to publish the revision, run git nostr pr update. Pass --force to replace the PR tip after rewriting the branch.

Checking out a pull request
git nostr pr checkout <nevent>
git nostr pr checkout <nevent> --branch review-feature

Use the original PR's nevent. The command creates and checks out a new branch at the latest eligible revision and associates it with the PR. If the branch name is taken, supply a different name with --branch.

To fetch a PR tip for inspection, use Git directly:

git fetch nostr://<nevent> HEAD
git log FETCH_HEAD

Pushing changes to a PR branch uses the Git remote you select, normally your own origin. Write access to the Git host and permission to publish a PR revision are separate. An unauthorized PR update leaves the Git push unaffected.

Patches

Publish commits as a patch series:

git nostr send-patch HEAD~3..HEAD

A patch or patch series can be retrieved and applied using:

git nostr am <nevent>

Restoring a repository

A personal repository can be cloned on another machine using its Nostr identity:

git clone nostr://<nip05>/<identifier>
cd project

The remote helper restores the origin and, where applicable, upstream remotes.

Retrieve branches with ordinary Git commands. To resume work on a PR in a new local branch with its association in place, run git nostr pr checkout <nevent> --branch review-feature.

Scope

The commands extend Git's repository, commit, branch, and patch operations.

General Nostr collaboration functionality (comments, discussions, reviews, labels, workflow states, notifications, and permission administration) is outside the scope of these tools.

Directories

Path Synopsis
cmd
git-nostr command
internal
git
Package git accesses repositories through the installed Git executable.
Package git accesses repositories through the installed Git executable.
metadata
Package metadata edits the display fields and clone URLs of a Nostr repository.
Package metadata edits the display fields and clone URLs of a Nostr repository.
publish
Package publish constructs, signs, and publishes NIP-34 events.
Package publish constructs, signs, and publishes NIP-34 events.
relay
Package relay sends and receives Nostr events through a fixed set of relays.
Package relay sends and receives Nostr events through a fixed set of relays.
resolve
Package resolve handles Nostr repository references, event pointers, and Git URLs.
Package resolve handles Nostr repository references, event pointers, and Git URLs.
settings
Package settings reads Git Nostr settings from Git configuration.
Package settings reads Git Nostr settings from Git configuration.
signing
Package signing loads the explicitly configured Nostr signing identity.
Package signing loads the explicitly configured Nostr signing identity.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL