Git for Windows (also known as msysgit) how to remember the user name and password (test)

Source: Internet
Author: User

If you like the command line, you need to enter the password each time to pull and submit. If you are not using SSH

In the following example, no account password is entered in HTTP https mode. No matter whether it is submitted or pulled, it will be automatically recorded and saved once it is set.

Create a file that stores the user name and password

In the home folder, create a file under c: \ Documents ents and Settings \ administrator. git-credentials (cannot be directly created in windows. so there is a trick: first create a file named) git-credentials and then enter git bash using the command:

[Plain]
View plaincopy
  1. MV Git-credentials. Git-Credentials

Open the file in notepad and enter:

[SQL]
View plaincopy
  1. Https: // {username }:{ password} @ github.com

For example:

[Plain]
View plaincopy
  1. Https: // zhangsan: 123456@github.com

Save

Add config item

Right-click any folder and choose git bash.

Then enter:

[Plain]
View plaincopy
  1. Git config -- Global credential. helper store

After the execution is complete, check the c: \ Documents ents and Settings \ Administrator \. gitconfig file and find one more:

[Plain]
View plaincopy
  1. [Credential]
  2. Helper = store

It is successful.

Re-open the GIT bash window, and then submit it without entering the username and password.

Reference: Git-Credential-Cache (1) manual pagename

Git-Credential-Cache-helper to temporarily store passwords in memory

Synopsis
git config credential.helper 'cache [options]'
Description

This command caches credentials in memory for use by future git programs. The stored credentials never touch the disk, and are forgotten after a dead able timeout. The cache is accessible over a Unix domain
Socket, restricted to the current user by filesystem permissions.

You probably don't want to invoke this command directly; it is meant to be used as a credential helper by other parts of git. seegitcredentials (7) orExamplesBelow.

Options
-- Timeout <seconds>

Number of seconds to cache credentials (default: 900 ).

-- Socket <path>

Use<Path>To contact a running cache daemon (or start a new cache daemon if one is not started). defaults~ /. Git-Credential-Cache/socket. If your home
Directory is on a network-mounted filesystem, you may need to change this to a local filesystem.

Controlling the daemon

If you wowould like the daemon to exit early, forgetting all cached credentials before their timeout, you can issueExitAction:

git credential-cache exit
Examples

The point of this helper is to reduce the number of times you must type your username or password. For example:

$ git config credential.helper cache$ git push http://example.com/repo.gitUsername: <type your username>Password: <type your password>[work for 5 more minutes]$ git push http://example.com/repo.git[your credentials are used automatically]

You can provide options via the credential. helper configuration variable (this example drops the cache time to 5 minutes ):

$ git config credential.helper 'cache --timeout=300'

Source: http://blog.csdn.net/nsrainbow/article/details/9121131

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.