windows 从 Git 中删除凭据
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15381198/
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
Remove credentials from Git
提问by balexandre
I'm working with several repositories, but lately I was just working in our internal one and all was great.
我正在使用多个存储库,但最近我只是在我们的内部存储库中工作,一切都很棒。
Today I had to commit and push code into other one, but I'm having some troubles.
今天我不得不提交代码并将代码推送到另一个,但我遇到了一些麻烦。
$ git push appharbor master
error: The requested URL returned error: 403 while accessing https://[email protected]/mitivo.git/info/refs?service=git-receive-pack
fatal: HTTP request failed
There is nothing I can do, that would bring the password entry again.
我无能为力,这会再次输入密码。
How can I reset the credentials on my system so Git will ask me for the password of that repository?
如何重置系统上的凭据,以便 Git 询问我该存储库的密码?
I have tried:
我试过了:
git config --global --unset core.askpass
git config --global --unset core.askpass
in order to unset the password
为了取消密码
git config credential.helper 'cache --timeout=1'
git config credential.helper 'cache --timeout=1'
in order to avoid credentials cache...
为了避免凭据缓存...
Nothing seems to work; does anyone have a better idea?
似乎没有任何效果;有没有人有更好的主意?
回答by patthoyts
The Git credential cache runs a daemon process which caches your credentials in memory and hands them out on demand. So killing your git-credential-cache--daemon process throws all these away and results in re-prompting you for your password if you continue to use this as the cache.helper option.
Git 凭证缓存运行一个守护进程,该进程将您的凭证缓存在内存中并按需分发。因此,如果您继续使用它作为 cache.helper 选项,那么杀死您的 git-credential-cache--daemon 进程会丢弃所有这些并导致重新提示您输入密码。
You could also disable use of the Git credential cache using git config --global --unset credential.helper
. Then reset this, and you would continue to have the cached credentials available for other repositories (if any). You may also need to do git config --system --unset credential.helper
if this has been set in the system configuration file (for example, Git for Windows 2).
您还可以使用git config --global --unset credential.helper
. 然后重置它,您将继续拥有可用于其他存储库(如果有)的缓存凭据。git config --system --unset credential.helper
如果已在系统配置文件(例如,Git for Windows 2)中进行了设置,您可能还需要这样做。
On Windows you might be better off using the managerhelper (git config --global credential.helper manager
). This stores your credentials in the Windows credential store which has a Control Panel interface where you can delete or edit your stored credentials. With this store, your details are secured by your Windows login and can persist over multiple sessions. The managerhelper included in Git for Windows 2.x has replaced the earlier wincredhelper that was added in Git for Windows 1.8.1.1. A similar helper called winstoreis also available online and was used with GitExtensions as it offers a more GUI driven interface. The managerhelper offers the same GUI interface as winstore.
在 Windows 上,您最好使用管理器助手 ( git config --global credential.helper manager
)。这会将您的凭据存储在 Windows 凭据存储中,该凭据存储具有控制面板界面,您可以在其中删除或编辑存储的凭据。使用此存储,您的详细信息由您的 Windows 登录名保护,并且可以在多个会话中持续存在。Git for Windows 2.x 中包含的管理器帮助程序已经取代了在 Git for Windows 1.8.1.1 中添加的早期wincred帮助程序。一个名为winstore的类似帮助程序也可在线获得,并与 GitExtensions 一起使用,因为它提供了更多 GUI 驱动的界面。该经理助手提供了相同的GUI界面winstore。
Extract from the Windows 10 support pagedetailing the Windows credential manager:
摘自Windows 10 支持页面,详细介绍了 Windows 凭据管理器:
To open Credential Manager, type "credential manager" in the search box on the taskbar and select Credential Manager Control panel.
要打开凭据管理器,请在任务栏上的搜索框中键入“凭据管理器”,然后选择凭据管理器控制面板。
And then select Windows Credentialsto edit (=remove or modify) the stored git credentials for a given URL.
然后选择Windows 凭据以编辑(=删除或修改)给定 URL 的存储的 git 凭据。
回答by Venkataramana Madugula
If this problem comes on a Windows machine, do the following.
如果此问题出现在 Windows 计算机上,请执行以下操作。
- Go to Credential Manager
- Go to Windows Credentials
- Delete the entries under Generic Credentials
- Try connecting again. This time, it should prompt you for the correct username and password.
- 转到凭据管理器
- 转到 Windows 凭据
- 删除通用凭据下的条目
- 再次尝试连接。这一次,它应该提示您输入正确的用户名和密码。
回答by aaafly
Retype:
重新输入:
$ git config credential.helper store
And then you will be prompted to enter your credentials again.
然后系统将提示您再次输入凭据。
WARNING
警告
Using this helper will store your passwords unencrypted on disk
使用此助手会将您的密码未加密地存储在磁盘上
回答by Mourya
I faced the same issue as the OP. It was taking my old Git credentials stored somewhere on the system and I wanted to use Git with my new credentials, so I ran the command
我遇到了与 OP 相同的问题。它使用存储在系统某处的旧 Git 凭据,我想将 Git 与我的新凭据一起使用,所以我运行了命令
$ git config --system --list
It showed
这显示了
credential.helper=manager
Whenever I performed git push
it was taking my old username which I set long back, and I wanted to use new a GitHub account to push changes. I later found that my old GitHub account credentials was stored under
Control Panel→ User Accounts→ Credential Manager→ Manage Windows Credentials.
每当我执行git push
它时,我都会使用我很久以前设置的旧用户名,我想使用新的 GitHub 帐户来推送更改。后来我发现我的旧 GitHub 帐户凭据存储在
Control Panel→ User Accounts→ Credential Manager→ Manage Windows Credentials 下。
I just removed these credentials and when I performed git push
it asked me for my GitHub credentials, and it worked like a charm.
我刚刚删除了这些凭据,当我执行git push
它时,它要求我提供我的 GitHub 凭据,它就像一个魅力。
回答by Himanshu Aggarwal
Try using the below command.
尝试使用以下命令。
git credential-manager
Here you can get various options to manage your credentials (check the below screen).
在这里,您可以获得管理凭据的各种选项(检查以下屏幕)。
Or you can even directly try this command:
或者你甚至可以直接尝试这个命令:
git credential-manager uninstall
This will start prompting for passwords again on each server interaction request.
这将在每个服务器交互请求中再次开始提示输入密码。
回答by damix911
I found something that worked for me. When I wrote my comment to the OP I had failed to check the system config file:
我找到了对我有用的东西。当我向 OP 写评论时,我未能检查系统配置文件:
git config --system -l
shows a
显示一个
credential.helper=!github --credentials
line. I unset it with
线。我用
git config --system --unset credential.helper
and now the credentials are forgotten.
现在凭据被遗忘了。
回答by SoliQuiD
回答by Zhe Hu
git config --list
will show credential.helper = manager
(this is on a windows machine)
将显示credential.helper = manager
(这是在 Windows 机器上)
To disable this cached username/password for your current local git folder, simply enter
要为当前本地 git 文件夹禁用此缓存的用户名/密码,只需输入
git config credential.helper ""
This way, git will prompt for password every time, ignoring what's saved inside "manager".
这样,git 每次都会提示输入密码,而忽略“manager”中保存的内容。
回答by ericbn
In Windows 2003 Server with "wincred"*, none of the other answers helped me. I had to use cmdkey
.
在带有“wincred”* 的 Windows 2003 Server 中,其他答案都没有帮助我。我不得不使用cmdkey
.
cmdkey /list
lists all stored credentials.cmdkey /delete:Target
deletes the credential with "Target" name.
cmdkey /list
列出所有存储的凭据。cmdkey /delete:Target
删除具有“目标”名称的凭据。
(* By "wincred" I mean git config --global credential.helper wincred
)
(* 我的意思是“畏缩” git config --global credential.helper wincred
)
回答by Pratik Patel
This error appears when you are using multiple Git accounts on the same machine.
当您在同一台机器上使用多个 Git 帐户时会出现此错误。
If you are using macOS then you can remove the saved credentials of github.com.
如果您使用的是 macOS,那么您可以删除github.com的已保存凭据。
Please follow below steps to remove the github.comcredentials.
请按照以下步骤删除github.com凭据。
- Open Keychain Access
- Find github
- Select the github.comand Right click on it
- Delete "github.com"
- Try again to Push or Pull to git and it will ask for the credentials.
- Enter valid credentials for repository account.
Done