93

我最近将本地 Git 安装更新为1.8.1from 1.8.0.1.

我注意到,当我在 GitHub 上工作时,它不再提示我在推送时输入用户名和密码。

这让我很困扰,因为我认为每次都必须输入用户名和密码是一种很好的安全措施。(如果其他人使用我的电脑怎么办?)

我检查了以下内容:

  • 1.8.0.1在另一台计算机上仍然要求输入用户名和密码。
  • 我在 github 上的帐户仍然强制执行私有/安全控制。
  • 我使用的是 https 远程引用,而不是 ssh。
  • 为了更好的衡量,我检查了我的~/.ssh情人。那里没有错。
  • 没有将登录详细信息存储在~/.gitconfig单个<proj>/.git/config文件中。
  • 我也没有~/.netrc.
  • 我创建了一个新的虚拟存档:仍然没有提示我登录。

我在 git发行说明存档中找不到任何内容。

有谁知道这是否是一种新的 git 行为?如何恢复提示?

4

6 回答 6

142

使用 git 命令添加 -v 标志。例如 git pull -v

v stands for verify .

于 2016-02-19T10:18:40.600 回答
92

This is most likely because you have multiple accounts, like one private, one for work with GitHub.

SOLUTION On Windows, go to Start > Credential Manager > Windows Credentials and remove GitHub creds, then try pulling or pushing again and you will be prompted to relogin into GitHub

SOLUTION OnMac, issue following on terminal:

git remote set-url origin https://username@github.com/username/repo-name.git

by replacing 'username' with your GitHub username in both places and providing your GitHub repo name.

于 2019-06-12T20:52:19.307 回答
24

有了git config -l,我现在看到我有一个credential.helper=osxkeychain选择

这意味着凭证助手(最初在 1.7.10 中引入)现在生效,并将自动缓存通过 HTTP 访问远程存储库的密码。
(如“ GIT: Any way to set default login credentials? ”)

您可以完全禁用该选项,或仅对单个 repo禁用。

于 2013-02-01T10:48:18.037 回答
15

None of those worked for me. I was trying to clone a directory from a private git server and entered my credentials false and then it wouldn't let me try different credentials on subsequent tries, it just errored out immediately with an authentication error.

What did work was specifying the user name (mike-wise)in the url like this:

   git clone https://mike-wise@collab.somewhere.net/someuser/somerepo.git
于 2018-09-29T23:38:00.500 回答
5

Since the question was labeled with Github, adding another remote like https_origin and add the https connection can force you always to enter the password:

git remote add https_origin https://github.com/.../...
于 2016-06-27T09:58:41.993 回答
1

Addition to third answer: If you're using non-english Windows, you can find "Credentials Manager" through "Control panel" > "User Accounts" > "Credentials Manager" Icon of Credentials Manager

于 2020-09-11T09:20:35.290 回答