Is there a way to skip password typing when using

2018-12-31 00:02发布

I recently switched to synchronising my repositories to https:// on GitHub (due to firewall issues), and it asks for a password every time. It used to be that I had an SSH certificate, and it was enough. Is there a way to bypass the password in my case (using http/https)?

23条回答
梦该遗忘
2楼-- · 2018-12-31 00:42

You can also have Git store your credentials permanently using the following:

git config credential.helper store

Note: While this is convenient, Git will store your credentials in clear text in a local file (.git-credentials) under your project directory (see below for the "home" directory). If you don't like this, delete this file and switch to using the cache option.

If you want Git to resume to asking you for credentials every time it needs to connect to the remote repository, you can run this command:

git config --unset credential.helper

To store the passwords in .git-credentials in your %HOME% directory as opposed to the project directory: use the --global flag

git config --global credential.helper store
查看更多
流年柔荑漫光年
3楼-- · 2018-12-31 00:43

It wasn't immediately obvious to me that I needed to download the helper first! I found the credential.helper download at Atlassian's Permanently authenticating with Git repositories.

Quote:

Follow these steps if you want to use Git with credential caching on OS X:

Download the binary git-credential-osxkeychain.

Run the command below to ensure the binary is executable:

chmod a+x git-credential-osxkeychain

Put it in the directory /usr/local/bin.

Run the command below:

git config --global credential.helper osxkeychain
查看更多
泪湿衣
4楼-- · 2018-12-31 00:43

Simply include the login credentials as part of the URL:

git remote rm origin 
git remote add origin https://username:mypassword@github.com/path/to/repo.git
查看更多
弹指情弦暗扣
5楼-- · 2018-12-31 00:44

For Windows you can use the Git Credential Manager (GCM) plugin. It is currently maintained by Microsoft. The nice thing is that it saves the password in the Windows Credential Store, not as plain text.

There is an installer on the releases page of the project. This will also install the official version of Git for Windows with the credential manager built-in. It allows two-factor authentication for GitHub (and other servers). And has a graphical interface for initially logging in.

For Cygwin users (or users already using the official Git for Windows), you might prefer the manual install. Download the zip package from the releases page. Extract the package, and then run the install.cmd file. This will install to your ~/bin folder. (Be sure your ~/bin directory is in your PATH.) You then configure it using this command:

git config --global credential.helper manager

Git will then run the git-credential-manager.exe when authenticating to any server.

查看更多
孤独总比滥情好
6楼-- · 2018-12-31 00:44

After you clone repo, you can edit repo/.git/config and add some configuration like below:

[user]
    name = you_name
    password = you_password
[credential]
    helper = store

Then you won't be asked for username and password again.

查看更多
弹指情弦暗扣
7楼-- · 2018-12-31 00:44

This works for me I'm using Windows 10

git config --global credential.helper wincred
查看更多
登录 后发表回答