Home Explore Blog CI



git

2nd chunk of `Documentation/gitfaq.adoc`
e75f5d62ab087f8011fe3f233b1888bdd119f3b7bba1c7fe0000000100000fa0
 see linkgit:git-var[1] for details on the order in which these options are
consulted.
+
Note that in all cases, the editor value will be passed to the shell, so any
arguments containing spaces should be appropriately quoted.  Additionally, if
your editor normally detaches from the terminal when invoked, you should specify
it with an argument that makes it not do that, or else Git will not see any
changes.  An example of a configuration addressing both of these issues on
Windows would be the configuration `"C:\Program Files\Vim\gvim.exe" --nofork`,
which quotes the filename with spaces and specifies the `--nofork` option to
avoid backgrounding the process.

Credentials
-----------

[[http-credentials]]
How do I specify my credentials when pushing over HTTP?::
	The easiest way to do this is to use a credential helper via the
	`credential.helper` configuration.  Most systems provide a standard
	choice to integrate with the system credential manager.  For example,
	Git for Windows provides the `wincred` credential manager, macOS has the
	`osxkeychain` credential manager, and Unix systems with a standard
	desktop environment can use the `libsecret` credential manager.  All of
	these store credentials in an encrypted store to keep your passwords or
	tokens secure.
+
In addition, you can use the `store` credential manager which stores in a file
in your home directory, or the `cache` credential manager, which does not
permanently store your credentials, but does prevent you from being prompted for
them for a certain period of time.
+
You can also just enter your password when prompted.  While it is possible to
place the password (which must be percent-encoded) in the URL, this is not
particularly secure and can lead to accidental exposure of credentials, so it is
not recommended.

[[http-credentials-environment]]
How do I read a password or token from an environment variable?::
	The `credential.helper` configuration option can also take an arbitrary
	shell command that produces the credential protocol on standard output.
	This is useful when passing credentials into a container, for example.
+
Such a shell command can be specified by starting the option value with an
exclamation point.  If your password or token were stored in the `GIT_TOKEN`,
you could run the following command to set your credential helper:
+
----
$ git config credential.helper \
	'!f() { echo username=author; echo "password=$GIT_TOKEN"; };f'
----

[[http-reset-credentials]]
How do I change the password or token I've saved in my credential manager?::
	Usually, if the password or token is invalid, Git will erase it and
	prompt for a new one.  However, there are times when this doesn't always
	happen.  To change the password or token, you can erase the existing
	credentials and then Git will prompt for new ones.  To erase
	credentials, use a syntax like the following (substituting your username
	and the hostname):
+
----
$ echo url=https://author@git.example.org | git credential reject
----

[[multiple-accounts-http]]
How do I use multiple accounts with the same hosting provider using HTTP?::
	Usually the easiest way to distinguish between these accounts is to use
	the username in the URL.  For example, if you have the accounts `author`
	and `committer` on `git.example.org`, you can use the URLs
	https://author@git.example.org/org1/project1.git and
	https://committer@git.example.org/org2/project2.git.  This way, when you
	use a credential helper, it will automatically try to look up the
	correct credentials for your account.  If you already have a remote set
	up, you can change the URL with something like `git remote set-url
	origin https://author@git.example.org/org1/project1.git` (see
	linkgit:git-remote[1] for details).

[[multiple-accounts-ssh]]
How do I use multiple accounts with the same hosting provider using SSH?::
	With most hosting providers that support SSH, a single key pair uniquely
	identifies a user.  Therefore, to use multiple accounts, it's necessary

Title: Git Credentials and Authentication
Summary
This section of the Git FAQ provides guidance on managing credentials, including specifying credentials for HTTP pushes, using credential helpers, storing passwords securely, and handling multiple accounts with the same hosting provider using both HTTP and SSH.