# swarmops auth git-credential

> Release: 0.13.0 · Last changed: 2026-11-17 · Source: https://github.com/KeiaiLab/SwarmOps/blob/stable/docs/reference/commands/auth-git-credential.md

Answer git's credential-helper protocol from your login file.

For a plain git to use a login: git -c credential.helper='!so auth git-credential' push. git adds the operation as the last word and writes its request on stdin, key=value lines up to a blank line; at most 64 KiB are read. get prints two lines on stdout, username=x-access-token and password= with the login's token, when the request's protocol is https (or http to a loopback address) and its host is exactly a login's, port included, of a provider this build knows. For anything else it prints nothing and exits 0, and git asks its next helper. store, erase and any other word print nothing and change nothing: a remote that refuses the token does not remove the login.

It prints no envelope: stdout belongs to git. A login file that is refused, a request that cannot be read and a command line it refuses have their envelope on stderr, with its exit code, and nothing on stdout. It uses no store and needs no identity. No other command prints a token.

```yaml
title: "swarmops auth git-credential"
description: "Answer git's credential-helper protocol from your login file."
group: "auth"
since: "0.12.0"
mutates: false
identity_required: false
mcp_tool: ""
envelope_op: "auth_git_credential"
exit_codes: [0]
errors: []
syntax: "swarmops auth git-credential [OPTIONS] <OPERATION>"
```

## Syntax

```text
swarmops auth git-credential [OPTIONS] <OPERATION>
```

## Required arguments

### `OPERATION`

Syntax: `<OPERATION>`.

The operation git names: get, store or erase.

## Optional arguments

The command also takes the [global options](../cli.md#global-options).

## Examples

### CLI

No recorded example yet.

## Details

`auth git-credential` is the command git runs, not one a person types: it answers git's
[credential-helper protocol](https://git-scm.com/docs/gitcredentials) from your login file, so
that a plain `git` can use the token [`auth login`](../commands/auth-login.md) kept. SwarmOps's
own commands do not need it: `clone`, `fetch`, `push` and `sync` send the login's token
themselves ([Where the login is used](../commands/auth-login.md#where-the-login-is-used)).

It opens no store: `--repo` and `--as` are read and not used. It has no MCP tool: it speaks git's
protocol on stdin and stdout, and prints a token.

### Telling git to use it

For one command:

```sh
git -c credential.helper='!so auth git-credential' push
```

For every repository of yours:

```sh
git config --global credential.helper '!so auth git-credential'
```

git runs the helper when a remote asks for a credential, with the operation as its last word,
and asks its other helpers when this one has no answer. Name the binary by an absolute path where
`so` is not on the `PATH` git runs with.

### What it answers

git writes its request on stdin, `key=value` lines up to a blank line. At most 64 KiB are read.

| Operation | What happens |
| --- | --- |
| `get` | For a request a login is for, two lines on stdout: `username=x-access-token` and `password=` with the login's token. For any other request, nothing. |
| `store` | Nothing: the helper keeps only what `auth login` kept. |
| `erase` | Nothing: a remote that refuses the token does not remove the login. |
| any other word | Nothing. |

A request is one a login is for when both hold:

1. **The protocol** is `https`, or `http` with a host that is a literal loopback address.
2. **The host** is equal to a login's, port included: a login for `github.com` answers a request
   for `github.com` and for `github.com:443`, and none for `gist.github.com` or `github.com:8443`.
   Only a login of a provider this build knows is given.

The request's other keys (`path`, `username`, the ones newer gits add) are passed over. The
answer never says `quit`, so git stays free to ask its next helper. In every case without an
answer the exit code is 0 and both streams are empty.

```text
protocol=https
host=github.com

```

is answered

```text
username=x-access-token
password=<the token>
```

### Streams and failures

stdout belongs to git, so the command prints no envelope there. This is the only command that
prints a token, and it prints it on stdout alone.

A failure leaves stdout empty and puts its envelope on stderr, with the envelope's exit code;
git then goes on as if the helper had no answer, and shows what the helper wrote:

| Failure | Envelope |
| --- | --- |
| A login file that is refused ([`auth login`](../commands/auth-login.md#a-file-that-is-refused)) | `E_INVALID_ARG` with `details.auth_file` and the file's `details.reason` |
| A request longer than 64 KiB, or one that cannot be read | `E_INVALID_ARG`, `details.reason` `credential_request` |
| No operation, or a flag it does not know | `E_INVALID_ARG`, the usage error |

The login file is opened only for a `get` whose protocol and host could be a login's: `store`,
`erase` and a request for ssh never fail on the file. No envelope and no message holds the token
or what stdin held.

## Return information

`swarmops auth git-credential` prints no envelope on stdout, which git reads as a credential helper's: for `get` with a login for the request's host, a `username=` line and a `password=` line, and otherwise nothing. A login file that is refused, a request it cannot read and a command line it refuses have their envelope on stderr.

Envelope `op`: `auth_git_credential`.

Exit codes:

- `0`: Success.

## Errors

No golden step shows this command failing yet.

Any command that opens a store may also fail with a store error, such as [`E_NOT_A_REPO`](../errors.md#e_not_a_repo), [`E_IO`](../errors.md#e_io) or [`E_STORE_CORRUPT`](../errors.md#e_store_corrupt); a command line the grammar refuses is [`E_INVALID_ARG`](../errors.md#e_invalid_arg) (exit 2).

## See also

- [`swarmops auth login`](auth-login.md)
- [`swarmops auth status`](auth-status.md)
- [`swarmops auth logout`](auth-logout.md)
- [CLI reference](../cli.md)
- [Error codes](../errors.md)
