347 lines
8.8 KiB
HTML
347 lines
8.8 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of GITCREDENTIALS</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>GITCREDENTIALS</H1>
|
|
Section: Git Manual (7)<BR>Updated: 03/04/2021<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
gitcredentials - providing usernames and passwords to Git
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<P>
|
|
<PRE>
|
|
git config credential.<A HREF="https://example.com.username">https://example.com.username</A> myusername
|
|
git config credential.helper "$helper $options"
|
|
</PRE>
|
|
|
|
<P>
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
<P>
|
|
Git will sometimes need credentials from the user in order to perform operations; for example, it may need to ask for a username and password in order to access a remote repository over HTTP. This manual describes the mechanisms Git uses to request these credentials, as well as some features to avoid inputting these credentials repeatedly.
|
|
<A NAME="lbAE"> </A>
|
|
<H2>REQUESTING CREDENTIALS</H2>
|
|
|
|
<P>
|
|
Without any credential helpers defined, Git will try the following strategies to ask the user for usernames and passwords:
|
|
<P>
|
|
<DL COMPACT><DT id="1"><DD>
|
|
1.
|
|
|
|
|
|
If the
|
|
<B>GIT_ASKPASS</B>
|
|
environment variable is set, the program specified by the variable is invoked. A suitable prompt is provided to the program on the command line, and the user's input is read from its standard output.
|
|
</DL>
|
|
|
|
<P>
|
|
<DL COMPACT><DT id="2"><DD>
|
|
2.
|
|
|
|
|
|
Otherwise, if the
|
|
<B>core.askPass</B>
|
|
configuration variable is set, its value is used as above.
|
|
</DL>
|
|
|
|
<P>
|
|
<DL COMPACT><DT id="3"><DD>
|
|
3.
|
|
|
|
|
|
Otherwise, if the
|
|
<B>SSH_ASKPASS</B>
|
|
environment variable is set, its value is used as above.
|
|
</DL>
|
|
|
|
<P>
|
|
<DL COMPACT><DT id="4"><DD>
|
|
4.
|
|
|
|
|
|
Otherwise, the user is prompted on the terminal.
|
|
</DL>
|
|
|
|
<A NAME="lbAF"> </A>
|
|
<H2>AVOIDING REPETITION</H2>
|
|
|
|
<P>
|
|
It can be cumbersome to input the same credentials over and over. Git provides two methods to reduce this annoyance:
|
|
<P>
|
|
<DL COMPACT><DT id="5"><DD>
|
|
1.
|
|
|
|
|
|
Static configuration of usernames for a given authentication context.
|
|
</DL>
|
|
|
|
<P>
|
|
<DL COMPACT><DT id="6"><DD>
|
|
2.
|
|
|
|
|
|
Credential helpers to cache or store passwords, or to interact with a system password wallet or keychain.
|
|
</DL>
|
|
|
|
<P>
|
|
The first is simple and appropriate if you do not have secure storage available for a password. It is generally configured by adding this to your config:
|
|
<P>
|
|
<DL COMPACT><DT id="7"><DD>
|
|
|
|
|
|
|
|
<PRE>
|
|
[credential "<A HREF="https://example.com">https://example.com</A>"]
|
|
username = me
|
|
</PRE>
|
|
|
|
</DL>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
<P>
|
|
Credential helpers, on the other hand, are external programs from which Git can request both usernames and passwords; they typically interface with secure storage provided by the OS or other programs.
|
|
<P>
|
|
To use a helper, you must first select one to use. Git currently includes the following helpers:
|
|
<P>
|
|
|
|
cache
|
|
<DL COMPACT><DT id="8"><DD>
|
|
Cache credentials in memory for a short period of time. See
|
|
<B><A HREF="/cgi-bin/man/man2html?1+git-credential-cache">git-credential-cache</A></B>(1)
|
|
for details.
|
|
</DL>
|
|
|
|
<P>
|
|
|
|
store
|
|
<DL COMPACT><DT id="9"><DD>
|
|
Store credentials indefinitely on disk. See
|
|
<B><A HREF="/cgi-bin/man/man2html?1+git-credential-store">git-credential-store</A></B>(1)
|
|
for details.
|
|
</DL>
|
|
|
|
<P>
|
|
You may also have third-party helpers installed; search for <B>credential-*</B> in the output of <B>git help -a</B>, and consult the documentation of individual helpers. Once you have selected a helper, you can tell Git to use it by putting its name into the credential.helper variable.
|
|
<P>
|
|
<DL COMPACT><DT id="10"><DD>
|
|
1.
|
|
|
|
|
|
Find a helper.
|
|
<P>
|
|
<DL COMPACT><DT id="11"><DD>
|
|
|
|
|
|
|
|
<PRE>
|
|
$ git help -a | grep credential-
|
|
credential-foo
|
|
</PRE>
|
|
|
|
</DL>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
</DL>
|
|
|
|
<P>
|
|
<DL COMPACT><DT id="12"><DD>
|
|
2.
|
|
|
|
|
|
Read its description.
|
|
<P>
|
|
<DL COMPACT><DT id="13"><DD>
|
|
|
|
|
|
|
|
<PRE>
|
|
$ git help credential-foo
|
|
</PRE>
|
|
|
|
</DL>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
</DL>
|
|
|
|
<P>
|
|
<DL COMPACT><DT id="14"><DD>
|
|
3.
|
|
|
|
|
|
Tell Git to use it.
|
|
<P>
|
|
<DL COMPACT><DT id="15"><DD>
|
|
|
|
|
|
|
|
<PRE>
|
|
$ git config --global credential.helper foo
|
|
</PRE>
|
|
|
|
</DL>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
</DL>
|
|
|
|
<A NAME="lbAG"> </A>
|
|
<H2>CREDENTIAL CONTEXTS</H2>
|
|
|
|
<P>
|
|
Git considers each credential to have a context defined by a URL. This context is used to look up context-specific configuration, and is passed to any helpers, which may use it as an index into secure storage.
|
|
<P>
|
|
For instance, imagine we are accessing <B><A HREF="https://example.com/foo.git">https://example.com/foo.git</A></B>. When Git looks into a config file to see if a section matches this context, it will consider the two a match if the context is a more-specific subset of the pattern in the config file. For example, if you have this in your config file:
|
|
<P>
|
|
<DL COMPACT><DT id="16"><DD>
|
|
|
|
|
|
|
|
<PRE>
|
|
[credential "<A HREF="https://example.com">https://example.com</A>"]
|
|
username = foo
|
|
</PRE>
|
|
|
|
</DL>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
<P>
|
|
then we will match: both protocols are the same, both hosts are the same, and the "pattern" URL does not care about the path component at all. However, this context would not match:
|
|
<P>
|
|
<DL COMPACT><DT id="17"><DD>
|
|
|
|
|
|
|
|
<PRE>
|
|
[credential "<A HREF="https://kernel.org">https://kernel.org</A>"]
|
|
username = foo
|
|
</PRE>
|
|
|
|
</DL>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
<P>
|
|
because the hostnames differ. Nor would it match <B>foo.example.com</B>; Git compares hostnames exactly, without considering whether two hosts are part of the same domain. Likewise, a config entry for <B><A HREF="http://example.com">http://example.com</A></B> would not match: Git compares the protocols exactly.
|
|
<P>
|
|
If the "pattern" URL does include a path component, then this too must match exactly: the context <B><A HREF="https://example.com/bar/baz.git">https://example.com/bar/baz.git</A></B> will match a config entry for <B><A HREF="https://example.com/bar/baz.git">https://example.com/bar/baz.git</A></B> (in addition to matching the config entry for <B><A HREF="https://example.com">https://example.com</A></B>) but will not match a config entry for <B><A HREF="https://example.com/bar">https://example.com/bar</A></B>.
|
|
<A NAME="lbAH"> </A>
|
|
<H2>CONFIGURATION OPTIONS</H2>
|
|
|
|
<P>
|
|
Options for a credential context can be configured either in <B>credential.*</B> (which applies to all credentials), or <B>credential.<url>.*</B>, where <url> matches the context as described above.
|
|
<P>
|
|
The following options are available in either location:
|
|
<P>
|
|
|
|
helper
|
|
<DL COMPACT><DT id="18"><DD>
|
|
The name of an external credential helper, and any associated options. If the helper name is not an absolute path, then the string
|
|
<B>git credential-</B>
|
|
is prepended. The resulting string is executed by the shell (so, for example, setting this to
|
|
<B>foo --option=bar</B>
|
|
will execute
|
|
<B>git credential-foo --option=bar</B>
|
|
via the shell. See the manual of specific helpers for examples of their use.
|
|
<P>
|
|
If there are multiple instances of the
|
|
<B>credential.helper</B>
|
|
configuration variable, each helper will be tried in turn, and may provide a username, password, or nothing. Once Git has acquired both a username and a password, no more helpers will be tried.
|
|
<P>
|
|
If
|
|
<B>credential.helper</B>
|
|
is configured to the empty string, this resets the helper list to empty (so you may override a helper set by a lower-priority config file by configuring the empty-string helper, followed by whatever set of helpers you would like).
|
|
</DL>
|
|
|
|
<P>
|
|
|
|
username
|
|
<DL COMPACT><DT id="19"><DD>
|
|
A default username, if one is not provided in the URL.
|
|
</DL>
|
|
|
|
<P>
|
|
|
|
useHttpPath
|
|
<DL COMPACT><DT id="20"><DD>
|
|
By default, Git does not consider the "path" component of an http URL to be worth matching via external helpers. This means that a credential stored for
|
|
<B><A HREF="https://example.com/foo.git">https://example.com/foo.git</A></B>
|
|
will also be used for
|
|
<B><A HREF="https://example.com/bar.git">https://example.com/bar.git</A></B>. If you do want to distinguish these cases, set this option to
|
|
<B>true</B>.
|
|
</DL>
|
|
|
|
<A NAME="lbAI"> </A>
|
|
<H2>CUSTOM HELPERS</H2>
|
|
|
|
<P>
|
|
You can write your own custom helpers to interface with any system in which you keep credentials. See credential.h for details.
|
|
<A NAME="lbAJ"> </A>
|
|
<H2>GIT</H2>
|
|
|
|
<P>
|
|
Part of the <B><A HREF="/cgi-bin/man/man2html?1+git">git</A></B>(1) suite
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="21"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="22"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="23"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="24"><A HREF="#lbAE">REQUESTING CREDENTIALS</A><DD>
|
|
<DT id="25"><A HREF="#lbAF">AVOIDING REPETITION</A><DD>
|
|
<DT id="26"><A HREF="#lbAG">CREDENTIAL CONTEXTS</A><DD>
|
|
<DT id="27"><A HREF="#lbAH">CONFIGURATION OPTIONS</A><DD>
|
|
<DT id="28"><A HREF="#lbAI">CUSTOM HELPERS</A><DD>
|
|
<DT id="29"><A HREF="#lbAJ">GIT</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:06:08 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|