Description
A remote is another copy of the repository that you fetch from and push to, usually on a server. With no arguments, grit remote lists your remotes and their URLs, sorted by name. Like git remote, the list includes a remote that has config but no URL, shown as (no url).
grit remote add adds a remote. It writes remote.<name>.url and the fetch refspec +refs/heads/*:refs/remotes/<name>/* to the repository's shared config, also when run from a linked worktree. It fails if a remote with that name is already configured, or if the name could not be used in a ref such as refs/remotes/<name>/main (for example names with spaces, .. or :). With --fetch (long only; -f means force elsewhere in grit), it runs grit fetch for that remote immediately after adding it. grit fetch stores the remote's branches as remote-tracking branches named <name>/<branch>, such as origin/main. grit clone adds a remote called origin for you.
grit remote prune deletes stale remote-tracking refs for one remote without fetching: it lists refs on the remote, compares them to local tracking refs under that remote's fetch refspecs (same rules as git fetch --prune), and removes refs whose upstream branch is gone. refs/remotes/<name>/HEAD is never pruned. --dry-run lists refs that would be removed without deleting them.
grit remote set-head updates or deletes the refs/remotes/<name>/HEAD symref. --auto queries the remote default branch and points HEAD at refs/remotes/<name>/<branch> when that tracking ref exists locally. A branch argument sets HEAD to that branch. --delete removes the symref. --dry-run reports the change without updating refs.
-v / --verbose lists fetch and push URLs on separate lines (name url (fetch) and name url (push)), like git remote -v. With --json, each remote also includes fetch_url and push_url after url.*.insteadOf / pushInsteadOf rewrites, plus refspecs.
grit remote set-url changes the fetch URL (remote.<name>.url) or, with --push, replaces every remote.<name>.pushurl with a single new push URL. It fails when the remote is not configured. --dry-run reports the change without writing config.
grit remote remove deletes a configured remote: it removes the remote.<name> section from the shared config, deletes every remote-tracking ref this remote's fetch refspecs map to (including refs/remotes/<name>/HEAD), and clears branch.<b>.remote, branch.<b>.merge, and matching branch.<b>.pushRemote / remote.pushDefault keys. Tracking refs that another remote's fetch refspec also maps to are kept. --dry-run reports what would change without writing config or refs. There is no rm alias.
grit remote show summarizes one configured remote: fetch and push URLs, the remote HEAD branch, each remote branch classified as tracked, new, or stale (when the remote is queried), and local branches whose branch.<name>.remote points at this remote. By default it contacts the remote (same transports as grit fetch). With --no-query, branch rows come from local remote-tracking refs only and every branch is reported as tracked.
grit remote rename renames a configured remote. When the remote uses the default fetch refspec into refs/remotes/<name>/, every remote-tracking ref is renamed in one transaction (reflogs preserved), then the config section is renamed, default fetch refspecs are updated, and branch.*.remote, branch.*.pushRemote, and remote.pushDefault entries that pointed at the old name are retargeted. Custom fetch refspecs that do not map into refs/remotes/<old>/ are left unchanged. --dry-run reports counts without changing the repository.
grit remote refs lists references on a configured remote name or a literal URL, scp-style host:path or path (same transports as grit clone), matching git ls-remote ordering. An argument that is none of these fails with unknown remote. SSH URLs use the same GIT_SSH_COMMAND, GIT_SSH, and core.sshCommand resolution as grit clone and grit fetch. Like fetch, listing uses protocol.version from config (default 2): SSH sets GIT_PROTOCOL=version=N on the ssh child when N > 0, and adds -o SendEnv=GIT_PROTOCOL when the resolved program basename is ssh / ssh.exe (including a GIT_SSH_COMMAND line that starts with ssh), or when GIT_SSH_VARIANT=ssh.
Options
| Option | Description |
|---|---|
-v, --verbose |
With no subcommand, show fetch and push URLs (like git remote -v). |
add <name> <url> |
Add a remote called <name> at <url>. Fails if a remote with that name exists or the name is not valid in a ref. |
--fetch |
With add, fetch from the new remote after writing config. |
prune <name> |
Delete stale remote-tracking refs for <name>. --dry-run previews without deleting. |
set-head <name> … |
Set or delete refs/remotes/<name>/HEAD (--auto, a branch name, or --delete). |
--auto |
With set-head, follow the remote HEAD symref. |
--delete |
With set-head, remove the local HEAD symref. |
set-url <name> <url> |
Set the fetch URL for <name>. Use --push for pushurl. |
--push |
With set-url, update push URL(s) instead of fetch. |
remove <name> |
Remove remote <name> and its tracking refs. --dry-run previews without writing. |
show <name> |
Summarize <name> (URLs, HEAD branch, remote branches, pull config). |
--no-query |
With show, use local remote-tracking refs only; do not contact the remote. |
--dry-run |
With set-url, remove, or rename, show the change without writing. |
rename <old> <new> |
Rename remote <old> to <new>. Fails when <new> exists or is not a valid remote name. |
refs <remote-or-url> |
List refs on the remote (or URL). |
--heads |
With refs, only refs/heads/. |
--tags |
With refs, only refs/tags/. |
--sort |
With refs, name (default) or version (git ls-remote --sort=version:refname). |
--reverse |
With refs, reverse --sort order. |
-n, --limit |
With show or refs, return at most N branch or ref lines after sorting. |
<prefix>… |
With refs, optional ref prefixes (same rules as git ls-remote). |
JSON output
Schema: v1 · remote.add v1 · remote.remove v1 · remote.show v1 · remote.rename v1 · remote.refs v1 (set-url uses the main remote schema)
Pass --json for stable, scripting-friendly output:
| Field | Type | Meaning |
|---|---|---|
action |
string | list, add, set_url, remove, prune, set_head, show, rename, or refs. |
remotes |
array | For list, each remote with name and url; with -v, also fetch_url, push_url, and refspecs. |
name |
string | For add, set_url, remove, or show, the remote name. |
url |
string | For add or set_url, the remote URL or path. |
fetched |
boolean | For add, whether a fetch ran after adding (--fetch). |
refs_pruned |
array | For prune, full ref names deleted or that would be deleted. |
target |
string or null | For set_head, new symref target, or null when deleted. |
previous_target |
string or null | For set_head, symref target before the update, if any. |
kind |
string | For set_url, fetch or push. |
old_url |
string or null | For set_url, previous URL for that kind, if any. |
refs_deleted |
array | For remove, deleted remote-tracking ref names. |
branches_untracked |
array | For remove, local branch short names whose upstream keys were cleared. |
dry_run |
boolean | For set_url, remove, or rename, whether changes were only reported. |
fetch_url |
string | For show, fetch URL after config rewrite. |
push_url |
string | For show, push URL (pushurl when set). |
head_branch |
string or null | For show, remote default branch when known. |
branches |
array | For show, each { name, state } with state tracked, new, or stale. |
pull |
array | For show, each { local, merges } from branch.* config. |
old |
string | For rename, the previous remote name. |
new |
string | For rename, the new remote name. |
refs_renamed |
number | For rename, remote-tracking refs renamed. |
refspecs_updated |
array | For rename, fetch refspec strings rewritten for the new name. |
branches_updated |
array | For rename, branch short names whose upstream remote was retargeted. |
refs |
array | For refs, each entry with name, oid, optional peeled, optional symref_target. |
Markdown output
Exit status
| Code | Meaning |
|---|---|
0 |
Success (success). |
1 |
Command failed (failure). |
2 |
Invalid flags or arguments (usage). |
128 |
remote refs could not reach or read the remote (remote_unreadable). |
See Exit codes for shared rules and structured --json kind values.