Page kind: Reference
swarmops auth git-credential#
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.
- Group
auth- Since
0.12.0- Mutates
- no
- Identity required
- no
- MCP tool
- none
- Envelope op
auth_git_credential- Exit codes
- 0
- Errors
- none
Syntax#
swarmops auth git-credential [OPTIONS] <OPERATION>Required arguments#
Syntax: <OPERATION>.
The operation git names: get, store or erase.
Optional arguments#
The command also takes the global options.
Examples#
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 from your login file, so
that a plain git can use the token auth login 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).
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:
git -c credential.helper='!so auth git-credential' pushFor every repository of yours:
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:
- The protocol is
https, orhttpwith a host that is a literal loopback address. - The host is equal to a login's, port included: a login for
github.comanswers a request forgithub.comand forgithub.com:443, and none forgist.github.comorgithub.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.
protocol=https
host=github.com
is answered
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) | 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, E_IO or E_STORE_CORRUPT; a command line the grammar refuses is E_INVALID_ARG (exit 2).