简体   繁体   English

Git 凭证助手 - 更新密码

[英]Git credential helper - update password

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?我将如何 go 关于在 Windows 7 上更新我的 git-credentials helper 密码?

None of these answers ended up working for my Git credential issue.这些答案最终都没有解决我的 Git 凭证问题。 Here is what did work if anyone needs it (I'm using Git 1.9 on Windows 8.1).如果有人需要它,这确实有效(我在 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

On my first attempt to Git fetch after my password change, I was told that my username/password combination was invalid.在我更改密码后第一次尝试 Git fetch 时,我被告知我的用户名/密码组合无效。 This was correct as git-credential helper had cached my old values.这是正确的,因为 git-credential 助手缓存了我的旧值。

However, I attempted another git fetch after 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!我希望这个答案可以帮助将来处于类似位置的其他人!

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.您单击 Git 右侧的下拉箭头:它将显示编辑和删除选项。 If you remove, the credential popup will come next time when you fetch or pull.如果您删除,则下次获取或拉取时会出现凭据弹出窗口。 Or you can directly edit the credentials there.或者您可以直接在那里编辑凭据。

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/push command it generates the authentication failed message.如果您已在 GitHub 服务器上更新了 GitHub 密码,则在git fetch/pull/push命令的第一次尝试中,它会生成身份验证失败消息。

Execute the same git fetch/pull/push command a second time and it prompts for credentials (username and password).再次执行相同的git fetch/pull/push命令,它会提示输入凭据(用户名和密码)。 Enter the username and the new updated password of the GitHub server and login will be successful.输入GitHub服务器的用户名和更新后的密码,登录成功。

Even I had this problem, and I performed the above steps and done!!即使我也有这个问题,我执行了上述步骤并完成了!!

First find the version you are using with the Git command git --version .首先通过 Git 命令git --version找到您正在使用的git --version If you have a newer version than 1.7.10, then simply use this command:如果您的版本高于 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 中多次提示输入密码。

It seems to me that the answers here are outdated.在我看来,这里的答案已经过时了。 For me using Git v2.15.0 this did the job:对我来说,使用 Git v2.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 permit - 正如Git 凭证的典型使用(第 4 步)中提到的 - 告诉凭证助手将凭证标记为已批准并在将来重用它们连接。

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.即时解决方案是删除或修复 Windows 凭据管理器中的 Git 条目。 You may have a hard time finding it in your localized Windows version, but luckily you can start it from the good old Windows + R run dialog with control keymgr.dll or control /name Microsoft.CredentialManager (or rundll32.exe keymgr.dll, KRShowKeyMgr if you prefer the classic look).你可能也很难在本地化Windows版本发现它,但幸运的是,你可以用好旧的Windows + R运行对话框启动control keymgr.dllcontrol /name Microsoft.CredentialManager (或rundll32.exe keymgr.dll, KRShowKeyMgr如果您更喜欢经典外观)。 Or put this in a batch file for your colleagues: cmdkey /delete:git:http://your.git.server.company.com .或者把它放在一个批处理文件中给你的同事: cmdkey /delete:git:http://your.git.server.company.com

In Microsoft's Git Credential Manager this is a known issue that may be fixed as soon as early 2019 (so don't hold your breath).在 Microsoft 的 Git Credential Manager 中,这是一个已知问题,最快可能会在 2019 年初修复(所以不要屏住呼吸)。

Update (2020-09-30) : GCM4W seems to be more or less abandoned (last release more than a year ago, only one commit to master since then named, I kid you not, "Recreate the scalable version of the GCM Logo").更新(2020-09-30) :GCM4W 似乎或多或少被抛弃了(上次发布是一年多前,从那时起只有一个 commit to master,我不骗你,“重新创建 GCM Logo 的可扩展版本” )。 But don't despair, with Microsoft now going Core, there is a shiny new project called GCM Core , which seems to handle password changes correctly.但是不要绝望,随着微软现在转向 Core,有一个名为GCM Core的闪亮新项目,它似乎可以正确处理密码更改。 It can be installed standalone (should be activated automatically, otherwise activate eg with git config --system credential.helper manager-core ) but is also included in the current Git for Windows 2.28.0.它可以独立安装(应该自动激活,否则使用git config --system credential.helper manager-core激活)但也包含在当前的 Windows 2.28.0 Git 中。 For more information about it, see this blog post .有关它的更多信息,请参阅此博客文章

Working solution for Windows:适用于 Windows 的工作解决方案:

Control Panel > User Accounts > Credential Manager > Generic Credentials控制面板 > 用户帐户 > 凭证管理器 > 通用凭证

在此处输入图片说明

Just cd in the directory where you have installed git-credential-winstore.只需在安装 git-credential-winstore 的目录中cd即可。 If you don't know where, just run this in Git Bash:如果你不知道在哪里,只需在 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.在这种情况下,您的存储库是 C:\\ProgramFile\\GitCredStore。 Once you are inside this folder using Git Bash or the Windows command, just type:使用 Git Bash 或 Windows 命令进入此文件夹后,只需键入:

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

Don't forget to press Enter twice after protocol=https .不要忘记在protocol=https后按Enter两次。

None of the current solutions worked for me with git bash 2.26.2.当前的解决方案都不适用于 git bash 2.26.2。 This should work in any case if you are using the windows credential manager.如果您使用 Windows 凭据管理器,这应该在任何情况下都有效。

One issue is the windows credential manager runs for the logged user.一个问题是为登录用户运行的 Windows 凭据管理器。 In my case for example, I run git bash with right click, run as admin.例如,在我的情况下,我右键单击运行 git bash,以管理员身份运行。 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,则无法使用 Windows GUI 访问该凭据。

To fix this:要解决此问题:

  • Open a cmd as admin (or whatever user you run with bash with)以管理员身份打开一个 cmd(或者你用 bash 运行的任何用户)
  • Go to windows/system32转到 windows/system32
  • Type cmdkey /list . cmdkey /list Your old credentials should appear here, with a part that reads ...target: xxx ...您的旧凭据应显示在此处,其中一部分内容为 ...target: xxx ...
  • Type cmdkey /delete:xxx , where xxx is the target from the previous line键入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 中执行任何需要身份验证的操作时,弹出窗口将询问您的凭据。

For Windows 10 it is:对于 Windows 10,它是:

Control Panel > User Accounts > Manage your Credentials > Windows Credentials, search for the git credentials and edit控制面板 > 用户帐户 > 管理您的凭据 > Windows 凭据,搜索 git 凭据并编辑

If you have reset your password, hence you are getting Auth failure error in the git bash command window.如果您已重置密码,则会在 git bash 命令窗口中收到 Auth failure 错误。 (it does not show popup where you could enter new password). (它不会显示您可以在其中输入新密码的弹出窗口)。

In the git bash cmd window enter following command:在 git bash cmd 窗口中输入以下命令:

$ git config --global credential.helper wincred

Some times it will show popup to enter the new password or Sometimes popup will be displayed when you are trying to do $git clone ..command有时它会显示弹出窗口以输入新密码,或者有时当您尝试执行$git clone ..command 时会显示弹出窗口

If you keep getting "fatal: Authentication failed for "https://......git" and you are unable to update the password.如果你不断收到“fatal: Authentication failed for "https://......git”并且你无法更新密码。

  1. $ git config --global credential.helper wincred $ git 配置 --global credential.helper wincred
  2. git clone -b..git git 克隆-b..git
  3. Popup will be displayed for username password将显示用户名密码的弹出窗口
  4. enter the new password输入新密码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM