Git 凭证助手 - 更新密码

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25845963/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 02:28:05  来源:igfitidea点击:

Git credential helper - update password

gitgithubwindows-7-x64change-passwordgit-credential-winstore

提问by Andrew Thomson

I'm currently using GitHub over HTTPS and have the latest version of Git installed (1.9.0) along with the Git credential helper on Windows 7.

我目前正在通过 HTTPS 使用 GitHub,并在 Windows 7 上安装了最新版本的 Git (1.9.0) 以及 Git 凭据帮助程序。

On setting up my environment, I told git-credentials to permanently remember my username and password.

在设置我的环境时,我告诉 git-credentials 永久记住我的用户名和密码。

I've recently updated my GitHub password via the website and I'm now no longer able to push/pull/fetch, etc.

我最近通过网站更新了我的 GitHub 密码,现在我无法再进行推/拉/获取等操作。

How I would go about updating my password on git-credentials helper on Windows 7?

我将如何在 Windows 7 上的 git-credentials 助手上更新我的密码?

采纳答案by Andrew Thomson

On my first attempt to Git fetch after my password change, I was told that my username/password combination was invalid. This was correct as git-credential helper had cached my old values.

在我更改密码后第一次尝试 Git fetch 时,我被告知我的用户名/密码组合无效。这是正确的,因为 git-credential 助手缓存了我的旧值。

However, I attempted another git fetchafter restarting my terminal/command-prompt and this time the credential helper prompted me to enter in my GitHub username and password.

但是,我在重新启动终端/命令提示符后尝试了另一个git fetch,这次凭证助手提示我输入我的 GitHub 用户名和密码。

I suspect the initial failed Git fetch request in combination with restarting my terminal/command-prompt resolved this for me.

我怀疑最初失败的 Git fetch 请求结合重新启动我的终端/命令提示符为我解决了这个问题。

I hope this answer helps anybody else in a similar position in the future!

我希望这个答案可以帮助将来处于类似位置的其他人!

回答by xgo

None of these answers ended up working for my Git credential issue. Here is what did work if anyone needs it (I'm using Git 1.9 on Windows 8.1).

这些答案最终都没有解决我的 Git 凭证问题。如果有人需要它,这确实有效(我在 Windows 8.1 上使用 Git 1.9)。

To update your credentials, go to Control PanelCredential ManagerGeneric Credentials. Find the credentials related to your Git account and edit them to use the updated password.

要更新您的凭证,请转至控制面板凭证管理器通用凭证。找到与您的 Git 帐户相关的凭据并编辑它们以使用更新后的密码。

Reference: How to update your Git credentials on Windows

参考:如何在 Windows 上更新您的 Git 凭据

Note that to use the Windows Credential Manager for Git you need to configure the credential helper like so:

请注意,要使用适用于 Git 的 Windows 凭据管理器,您需要像这样配置凭据助手:

git config --global credential.helper wincred

If you have multiple GitHub accounts that you use for different repositories, then you should configure credentials to use the full repository path (rather than just the domain, which is the default):

如果您有多个 GitHub 帐户用于不同的存储库,那么您应该配置凭据以使用完整的存储库路径(而不仅仅是域,这是默认值):

git config --global credential.useHttpPath true

回答by Farooque

Solution using command line for Windows, Linux, and MacOS

使用命令行的 Windows、Linux 和 MacOS 解决方案

If you have updated your GitHub password on the GitHub server, in the first attempt of the git fetch/pull/pushcommand it generates the authentication failedmessage.

如果您已在 GitHub 服务器上更新了 GitHub 密码,则在第一次尝试该git fetch/pull/push命令时,它会生成身份验证失败消息。

Execute the same git fetch/pull/pushcommand a second time and it prompts for credentials (username and password). Enter the username and the new updated password of the GitHub server and login will be successful.

git fetch/pull/push再次执行相同的命令,它会提示输入凭据(用户名和密码)。输入GitHub服务器的用户名和更新后的密码,登录成功。

Even I had this problem, and I performed the above steps and done!!

即使我也有这个问题,我执行了上述步骤并完成了!!

回答by Vins

If you are a Windows user, you may either remove or update your credentials in Credential Manager.

如果您是 Windows 用户,则可以在 Credential Manager 中删除或更新您的凭据。

In Windows 10, go to the below path:

在 Windows 10 中,转到以下路径:

Control PanelAll Control Panel ItemsCredential Manager

控制面板所有控制面板项目凭证管理器

Or search for "credential manager" in your "Search Windows" section in the Start menu.

或者在“开始”菜单的“搜索窗口”部分中搜索“凭据管理器”。

Then from the Credential Manager, select "Windows Credentials".

然后从凭据管理器中,选择“Windows 凭据”。

Credential Manager will show many items including your outlook and GitHub repository under "Generic credentials"

凭据管理器将在“通用凭据”下显示许多项目,包括您的 Outlook 和 GitHub 存储库

You click on the drop down arrow on the right side of your Git: and it will show options to edit and remove. If you remove, the credential popup will come next time when you fetch or pull. Or you can directly edit the credentials there.

您单击 Git 右侧的下拉箭头:它将显示编辑和删除选项。如果您删除,则下次获取或拉取时会出现凭据弹出窗口。或者您可以直接在那里编辑凭据。

回答by Sireesh Yarlagadda

First find the version you are using with the Git command git --version. If you have a newer version than 1.7.10, then simply use this command:

首先通过 Git 命令找到您正在使用的版本git --version。如果您的版本高于 1.7.10,则只需使用以下命令:

git config --global credential.helper wincred

Then do the git fetch, then it prompts for the password update.

然后执行git fetch,然后它会提示密码更新。

Now, it won't prompt for the password for multiple times in Git.

现在,它不会在 Git 中多次提示输入密码。

回答by atavio

It seems to me that the answers here are outdated. For me under Windows 10 and Git 2.15.0 this did the job:

在我看来,这里的答案已经过时了。对于我在 Windows 10 和 Git 2.15.0 下,这完成了这项工作:

git credential reject
protocol=https
host=github.com
<Empty line here>

And then to set the new username & password:

然后设置新的用户名和密码:

git credential fill
protocol=https
host=github.com
<empty line here>

After this, if the credentials now work on the desired target host, we should use git credential approve-as mentioned in typical use of Git credentials(step 4)- to tell the credential helpers to mark the credentials as approved and reuse them in future connections.

在此之后,如果凭据现在可以在所需的目标主机上运行,​​我们应该使用git credential approve-正如Git 凭据的典型使用(第 4 步)中提到的- 告诉凭据助手将凭据标记为已批准并在未来的连接中重用它们。

回答by Jakob

FWIW, I stumbled over this very same problem (and my boss too, so it got more intense).

FWIW,我偶然发现了同样的问题(我的老板也是,所以它变得更加激烈)。

The instant solution is to delete or fix your Git entries in the Windows Credential Manager. You may have a hard time finding it in your localized Windows version, but luckily you can start it from the good old Windows+ Rrun dialog with control keymgr.dllor control /name Microsoft.CredentialManager(or rundll32.exe keymgr.dll, KRShowKeyMgrif you prefer the classic look). Or put this in a batch file for your colleagues: cmdkey /delete:git:http://your.git.server.company.com.

即时解决方案是删除或修复 Windows 凭据管理器中的 Git 条目。您可能很难在本地化的 Windows 版本中找到它,但幸运的是,您可以使用或(或者,如果您更喜欢经典外观)从旧的Windows+R运行对话框中启动它。或者把它放在一个批处理文件中给你的同事:.control keymgr.dllcontrol /name Microsoft.CredentialManagerrundll32.exe keymgr.dll, KRShowKeyMgrcmdkey /delete:git:http://your.git.server.company.com

In Microsoft's Git Credential Manager this is a known issuethat may be fixed as soon as early 2019 (so don't hold your breath).

在 Microsoft 的 Git Credential Manager 中,这是一个已知问题,最快可能会在 2019 年初修复(所以不要屏住呼吸)。

回答by Luc DUZAN

Just cdin the directory where you have installed git-credential-winstore. If you don't know where, just run this in Git Bash:

cd在您安装 git-credential-winstore 的目录中。如果你不知道在哪里,只需在 Git Bash 中运行它:

cat ~/.gitconfig

It should print something looking like:

它应该打印如下内容:

[credential]
    helper = !'C:\ProgramFile\GitCredStore\git-credential-winstore.exe'

In this case, you repository is C:\ProgramFile\GitCredStore. Once you are inside this folder using Git Bash or the Windows command, just type:

在这种情况下,您的存储库是 C:\ProgramFile\GitCredStore。使用 Git Bash 或 Windows 命令进入此文件夹后,只需键入:

git-credential-winstore.exe erase
host=github.com
protocol=https

Don't forget to press Entertwice after protocol=https.

之后不要忘记按Enter两次protocol=https

回答by Jorge.V

None of the current solutions worked for me with git bash 2.26.2. This should work in any case if you are using the windows credential manager.

当前的解决方案都不适用于 git bash 2.26.2。 如果您使用 Windows 凭据管理器,这应该在任何情况下都有效。

One issue is the windows credential manager runs for the logged user. In my case for example, I run git bash with right click, run as admin. Therefore, my stored credentials are in a credentials manager which I can't access with the windows GUI if I don't login to windows as admin.

一个问题是为登录用户运行的 Windows 凭据管理器。例如,在我的情况下,我右键单击运行 git bash,以管理员身份运行。因此,我存储的凭据位于凭据管理器中,如果我不以管理员身份登录 Windows,则无法使用 Windows GUI 访问该凭据。

To fix this:

要解决此问题:

  • Open a cmd as admin (or whatever user you run with bash with)
  • Go to windows/system32
  • Type cmdkey /list. Your old credentials should appear here, with a part that reads ...target:xxx...
  • Type cmdkey /delete:xxx, where xxx is the target from the previous line
  • 以管理员身份打开一个 cmd(或者你用 bash 运行的任何用户)
  • 转到 windows/system32
  • 键入cmdkey /list。您的旧凭据应显示在此处,其中一部分内容为 ...target: xxx...
  • 键入cmdkey /delete:xxx,其中 xxx 是上一行的目标

It should confirm you that your credentials have been removed. Next time you do any operation in git bash that requires authentication, a popup will ask for your credentials.

它应该确认您的凭据已被删除。下次您在 git bash 中执行任何需要身份验证的操作时,弹出窗口将询问您的凭据。