{
    "mode": "man",
    "parameter": "git-credential",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/git-credential/1/json",
    "generated": "2026-10-21T07:05:08Z",
    "synopsis": "'git credential' (fill|approve|reject)",
    "sections": {
        "NAME": {
            "content": "git-credential - Retrieve and store user credentials\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "'git credential' (fill|approve|reject)\n\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Git has an internal interface for storing and retrieving credentials from system-specific\nhelpers, as well as prompting the user for usernames and passwords. The git-credential\ncommand exposes this interface to scripts which may want to retrieve, store, or prompt for\ncredentials in the same manner as Git. The design of this scriptable interface models the\ninternal C API; see credential.h for more background on the concepts.\n\ngit-credential takes an \"action\" option on the command-line (one of fill, approve, or reject)\nand reads a credential description on stdin (see INPUT/OUTPUT FORMAT).\n\nIf the action is fill, git-credential will attempt to add \"username\" and \"password\"\nattributes to the description by reading config files, by contacting any configured\ncredential helpers, or by prompting the user. The username and password attributes of the\ncredential description are then printed to stdout together with the attributes already\nprovided.\n\nIf the action is approve, git-credential will send the description to any configured\ncredential helpers, which may store the credential for later use.\n\nIf the action is reject, git-credential will send the description to any configured\ncredential helpers, which may erase any stored credentials matching the description.\n\nIf the action is approve or reject, no output should be emitted.\n",
            "subsections": []
        },
        "TYPICAL USE OF GIT CREDENTIAL": {
            "content": "An application using git-credential will typically use git credential following these steps:\n\n1. Generate a credential description based on the context.\n\nFor example, if we want a password for https://example.com/foo.git, we might generate the\nfollowing credential description (don’t forget the blank line at the end; it tells git\ncredential that the application finished feeding all the information it has):\n\nprotocol=https\nhost=example.com\npath=foo.git\n\n2. Ask git-credential to give us a username and password for this description. This is done\nby running git credential fill, feeding the description from step (1) to its standard\ninput. The complete credential description (including the credential per se, i.e. the\nlogin and password) will be produced on standard output, like:\n\nprotocol=https\nhost=example.com\nusername=bob\npassword=secr3t\n\nIn most cases, this means the attributes given in the input will be repeated in the\noutput, but Git may also modify the credential description, for example by removing the\npath attribute when the protocol is HTTP(s) and credential.useHttpPath is false.\n\nIf the git credential knew about the password, this step may not have involved the user\nactually typing this password (the user may have typed a password to unlock the keychain\ninstead, or no user interaction was done if the keychain was already unlocked) before it\nreturned password=secr3t.\n\n3. Use the credential (e.g., access the URL with the username and password from step (2)),\nand see if it’s accepted.\n\n4. Report on the success or failure of the password. If the credential allowed the operation\nto complete successfully, then it can be marked with an \"approve\" action to tell git\ncredential to reuse it in its next invocation. If the credential was rejected during the\noperation, use the \"reject\" action so that git credential will ask for a new password in\nits next invocation. In either case, git credential should be fed with the credential\ndescription obtained from step (2) (which also contains the fields provided in step (1)).\n",
            "subsections": []
        },
        "INPUT/OUTPUT FORMAT": {
            "content": "git credential reads and/or writes (depending on the action used) credential information in\nits standard input/output. This information can correspond either to keys for which git\ncredential will obtain the login information (e.g. host, protocol, path), or to the actual\ncredential data to be obtained (username/password).\n\nThe credential is split into a set of named attributes, with one attribute per line. Each\nattribute is specified by a key-value pair, separated by an = (equals) sign, followed by a\nnewline.\n\nThe key may contain any bytes except =, newline, or NUL. The value may contain any bytes\nexcept newline or NUL.\n\nAttributes with keys that end with C-style array brackets [] can have multiple values. Each\ninstance of a multi-valued attribute forms an ordered list of values - the order of the\nrepeated attributes defines the order of the values. An empty multi-valued attribute\n(key[]=\\n) acts to clear any previous entries and reset the list.\n\nIn all cases, all bytes are treated as-is (i.e., there is no quoting, and one cannot transmit\na value with newline or NUL in it). The list of attributes is terminated by a blank line or\nend-of-file.\n\nGit understands the following attributes:\n",
            "subsections": [
                {
                    "name": "protocol",
                    "content": "The protocol over which the credential will be used (e.g., https).\n"
                },
                {
                    "name": "host",
                    "content": "The remote hostname for a network credential. This includes the port number if one was\nspecified (e.g., \"example.com:8088\").\n"
                },
                {
                    "name": "path",
                    "content": "The path with which the credential will be used. E.g., for accessing a remote https\nrepository, this will be the repository’s path on the server.\n"
                },
                {
                    "name": "username",
                    "content": "The credential’s username, if we already have one (e.g., from a URL, the configuration,\nthe user, or from a previously run helper).\n"
                },
                {
                    "name": "password",
                    "content": "The credential’s password, if we are asking it to be stored.\n"
                },
                {
                    "name": "password_expiry_utc",
                    "content": "Generated passwords such as an OAuth access token may have an expiry date. When reading\ncredentials from helpers, git credential fill ignores expired passwords. Represented as\nUnix time UTC, seconds since 1970.\n"
                },
                {
                    "name": "oauth_refresh_token",
                    "content": "An OAuth refresh token may accompany a password that is an OAuth access token. Helpers\nmust treat this attribute as confidential like the password attribute. Git itself has no\nspecial behaviour for this attribute.\n"
                },
                {
                    "name": "url",
                    "content": "When this special attribute is read by git credential, the value is parsed as a URL and\ntreated as if its constituent parts were read (e.g., url=https://example.com would behave\nas if protocol=https and host=example.com had been provided). This can help callers avoid\nparsing URLs themselves.\n\nNote that specifying a protocol is mandatory and if the URL doesn’t specify a hostname\n(e.g., \"cert:///path/to/file\") the credential will contain a hostname attribute whose\nvalue is an empty string.\n\nComponents which are missing from the URL (e.g., there is no username in the example\nabove) will be left unset.\n"
                },
                {
                    "name": "wwwauth[]",
                    "content": "When an HTTP response is received by Git that includes one or more WWW-Authenticate\nauthentication headers, these will be passed by Git to credential helpers.\n\nEach WWW-Authenticate header value is passed as a multi-valued attribute wwwauth[], where\nthe order of the attributes is the same as they appear in the HTTP response. This\nattribute is one-way from Git to pass additional information to credential helpers.\n\nUnrecognised attributes are silently discarded.\n"
                }
            ]
        },
        "GIT": {
            "content": "Part of the git(1) suite\n\nGit 2.43.0                                   07/02/2025                            GIT-CREDENTIAL(1)",
            "subsections": []
        }
    },
    "summary": "git-credential - Retrieve and store user credentials",
    "flags": [],
    "examples": [],
    "see_also": [],
    "tldr": {
        "source": "official",
        "description": "Retrieve and store user credentials.",
        "examples": [
            {
                "description": "Display credential information, retrieving the username and password from configuration files",
                "command": "echo \"{{url=http://example.com}}\" | git credential fill"
            },
            {
                "description": "Send credential information to all configured credential helpers to store for later use",
                "command": "echo \"{{url=http://example.com}}\" | git credential approve"
            },
            {
                "description": "Erase the specified credential information from all the configured credential helpers",
                "command": "echo \"{{url=http://example.com}}\" | git credential reject"
            }
        ]
    }
}