bal*_*dre 522 windows git credentials
我正在使用几个存储库,但最近我只是在内部工作,一切都很棒.
今天我不得不承诺并将代码推送到其他代码中,但我遇到了一些麻烦.
$ git push appharbor master
error: The requested URL returned error: 403 while accessing https://gavekortet@appharbor.com/mitivo.git/info/refs?service=git-receive-pack
fatal: HTTP request failed
Run Code Online (Sandbox Code Playgroud)
我无能为力,这将再次带来密码输入.
如何重置系统上的凭据,以便Git会询问我该存储库的密码?
我试过了:
git config --global --unset core.askpass为了取消设置密码
git config credential.helper 'cache --timeout=1'为了避免凭证缓存......
似乎没有任何作用; 有没有人有更好的主意?
pat*_*yts 589
Git凭证缓存运行一个守护程序进程,该进程将您的凭据缓存在内存中并按需将其移出.因此,如果您继续将此作为cache.helper选项使用,那么杀死您的git-credential-cache-daemon进程会抛弃所有这些并导致重新提示您输入密码.
您还可以使用禁用Git凭据缓存的使用git config --global --unset credential.helper.然后重置它,您将继续拥有其他存储库(如果有)的缓存凭据.git config --system --unset credential.helper如果已在系统配置文件中设置(例如,Git for Windows 2),则可能还需要执行此操作.
在Windows上,您可能最好使用管理器帮助程序(git config --global credential.helper manager).这会将您的凭据存储在Windows凭据存储中,该凭据存储具有控制面板界面,您可以在其中删除或编辑存储的凭据.使用此商店,您的详细信息将通过Windows登录进行保护,并且可以在多个会话中保留.Git for Windows 2.x中包含的管理器帮助程序已经取代了之前在Windows 1.8.1.1的Git中添加的wincred帮助程序.一个名为winstore的类似帮助程序也可以在线获得,并与GitExtensions一起使用,因为它提供了更多GUI驱动的界面.该经理助手提供了相同的GUI界面winstore.
从详细介绍Windows凭据存储面板的Windows手册中摘录:
通过单击"开始"按钮,"开始"按钮的图片,"控制面板","用户帐户和家庭安全"(或单击"用户帐户",如果已连接到网络域),然后单击"用户帐户",打开"用户帐户".在左窗格中,单击"管理您的凭据".
Ven*_*ula 516
如果Windows计算机上出现此问题,请执行以下操作.
aaa*_*fly 142
重新输入:
$ git config credential.helper store
Run Code Online (Sandbox Code Playgroud)
然后,系统将提示您再次输入凭据.
警告
使用此帮助程序会将未加密的密码存储在磁盘上
资料来源:https://git-scm.com/docs/git-credential-store
Mou*_*rya 88
我遇到了与OP相同的问题.它把我的旧Git凭据存储在系统的某个地方,我想用我的新凭据使用Git,所以我运行了命令
$ git config --system --list
Run Code Online (Sandbox Code Playgroud)
这显示了
credential.helper=manager
Run Code Online (Sandbox Code Playgroud)
每当我执行git push它时,都会使用我长期设置的旧用户名,并且我想使用新的GitHub帐户来推送更改.我后来发现我的旧GitHub帐户凭据存储在
控制面板 → 用户帐户 → 凭据管理器 → 管理Windows凭据下.
我刚刚删除了这些凭据,当我执行git push它时,它询问了我的GitHub凭据,它就像一个魅力.
Him*_*wal 45
尝试使用以下命令.
git credential-manager
Run Code Online (Sandbox Code Playgroud)
在这里,您可以获得管理凭据的各种选项(请查看以下屏幕).
或者你甚至可以直接尝试这个命令:
git credential-manager uninstall
Run Code Online (Sandbox Code Playgroud)
这将在每个服务器交互请求上再次开始提示输入密码.
dam*_*911 26
我找到了适合我的东西.当我向OP写评论时,我未能检查系统配置文件:
git config --system -l
Run Code Online (Sandbox Code Playgroud)
显示一个
credential.helper=!github --credentials
Run Code Online (Sandbox Code Playgroud)
线.我解开了
git config --system --unset credential.helper
Run Code Online (Sandbox Code Playgroud)
现在证书被遗忘了.
Zhe*_* Hu 14
git config --list
Run Code Online (Sandbox Code Playgroud)
将显示credential.helper = manager(这是在Windows机器上)
要禁用当前本地git文件夹的此缓存用户名/密码,只需输入即可
git config credential.helper ""
Run Code Online (Sandbox Code Playgroud)
这样,git每次都会提示输入密码,忽略"manager"中保存的内容.
Tah*_*lid 14
在 Windows 10 Professional 上使用适用于 Windows 的最新版本的 git,我遇到了类似的问题,即我有两个不同的 GitHub 帐户和一个 Bitbucket 帐户,因此对于 VS2017、git 扩展和 git bash,事情有点混乱。
我首先检查了 git 如何使用此命令处理我的凭据(使用提升的命令运行 git bash 否则您会收到错误):
git config --list
Run Code Online (Sandbox Code Playgroud)
我找到了 Credential Manager 条目,所以我点击了 START 按钮 > 输入 Credential Manager 到并左键单击启动应用程序的凭证管理器黄色安全图标。然后我点击 Windows Credentials 选项卡,找到了我当前 git 帐户的条目,它恰好是 Bit-bucket,所以我删除了这个帐户。
但这并没有解决问题,所以下一步是取消设置凭据,我从笔记本电脑上的存储库目录中执行此操作,该目录包含我试图推送到远程的 GitHub 项目。我输入了以下命令:
git config --system --unset credential.helper
Run Code Online (Sandbox Code Playgroud)
然后我做了一个 git push 并提示我输入一个我输入的 GitHub 用户名(我需要的正确用户名),然后是关联的密码,一切都被正确推送。
我不确定这会带来多大的问题,大多数人可能会在一个存储库中工作,但我必须跨多个并使用不同的提供程序工作,因此可能会再次遇到此问题。
Ami*_*t K 12
需要使用相应的github username和password
清除Windows中的用户名和密码
控制面板\用户帐户\凭据管理器
编辑窗口凭据
删除现有用户,现在转到命令提示符,写入push命令,显示一个github弹出窗口,输入username/ email和password.
现在我们可以在切换用户后推送代码.
小智 12
做'git pull'时得到同样的错误,这就是我修复它的方法.
ami*_*ree 12
如果您希望 git 忘记旧的保存凭据并重新输入用户名和密码,您可以使用以下命令执行此操作:
git credential-cache exit
Run Code Online (Sandbox Code Playgroud)
运行上述命令后,如果您尝试推送任何内容,它将提供输入用户名和密码的选项。
小智 11
如果您的凭据存储在凭据帮助程序中(通常是这种情况),则删除为特定主机保留的密码的便携式方法是调用git credential reject:
在一行中:
$ echo "url=https://appharbor.com" | git credential reject
Run Code Online (Sandbox Code Playgroud)
或交互:
$ git credential reject
protocol=https
host=gitlab.com
username=me@example.com
?
Run Code Online (Sandbox Code Playgroud)
之后,要输入新密码,请键入git fetch。
https://git-scm.com/docs/git-credential
Pra*_*tel 10
当您在同一台计算机上使用多个Git帐户时,会出现此错误。
如果您使用的是macOS,则可以删除github.com的已保存凭据。
请按照以下步骤删除github.com凭证。
从位于Windows当前登录用户文件夹中的.gitconfig文件中删除此行:
[credential]
helper = !\"C:/Program Files (x86)/GitExtensions/GitCredentialWinStore/git-credential-winstore.exe\"
Run Code Online (Sandbox Code Playgroud)
这对我有用,现在当我推送到远程它再次要求我的密码.
如果使用Git Credential Manager for Windows(当前版本通常这样做):
git credential-manager clear
Run Code Online (Sandbox Code Playgroud)
这是在2016年中期添加的.要检查是否使用了凭据管理器:
git config --global credential.helper
? manager
Run Code Online (Sandbox Code Playgroud)
小智 8
您必须在凭据管理器中对其进行更新。
转到控制面板>用户帐户>凭据管理器> Windows凭据。您将在列表中看到Git凭据(例如git:https://)。单击它,更新密码,然后从Git bash执行git pull / push命令,它不会再抛出任何错误消息。
没有给出任何答案对我有用。但这最终对我有用:
rm -rf ~/.git-credentials
Run Code Online (Sandbox Code Playgroud)
这将删除所有凭据!当您使用新git命令时,系统会要求您输入密码!
对于 macOS 用户:
当您在同一台机器上使用多个 Git 帐户时会出现此错误。
请按照以下步骤删除 github.com 凭据。
- 转到查找器
- 转到应用程序
- 转到实用程序文件夹
- 打开钥匙串访问
- 选择 github.com 并右键单击它
删除“github.com”
再次尝试 Push 或 Pull 到 git,它会要求提供凭据。输入存储库帐户的有效凭据。完成,现在赞成答案。
您可以credential.helper=!github --credentials从以下文件C:\Program Files\Git\mingw64\etc\gitconfig中删除该行,以删除git的凭据
在我的情况下,我找不到Windows凭据管理器(Windows 7)中保存的凭据.
我能够通过执行来重置我的凭据
git config --global credential.helper wincred
Run Code Online (Sandbox Code Playgroud)
老实说,这是玛丽,看看它是否会消灭我的凭据,它确实有效.
他的答案使用但没有解释localvs. globalvs.system配置。他们的官方 git 文档在这里,值得一读。
例如,我在 Linux 上,不使用系统配置,所以我从不使用--system标志,但通常需要区分--local和--global配置。
我的用例是我有两个 Github 凭证;一台用于工作,一台用于娱乐。
这是我处理问题的方法:
$ cd work
# do and commit work
$ git push origin develop
# Possibly prompted for credentials if I haven't configured my remotes to automate that.
# We're assuming that now I've stored my "work" credentials with git's credential helper.
$ cd ~/play
# do and commit play
$ git push origin develop
remote: Permission to whilei/specs.git denied to whilei.
fatal: unable to access 'https://github.com/workname/specs.git/': The requested URL returned error: 403
# So here's where it goes down:
$ git config --list | grep cred
credential.helper=store # One of these is for _local_
credential.helper=store # And one is for _global_
$ git config --global --unset credential.helper
$ git config --list | grep cred
credential.helper=store # My _local_ config still specifies 'store'
$ git config --unset credential.helper
$ git push origin develop
Username for 'https://github.com': whilei
Password for 'https://whilei@github.com':
Counting objects: 3, done.
Delta compression using up to 12 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 1.10 KiB | 1.10 MiB/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To https://github.com/whilei/specs.git
b2ca528..f64f065 master -> master
# Now let's turn credential-helping back on:
$ git config --global credential.helper "store"
$ git config credential.helper "store"
$ git config --list | grep cred
credential.helper=store # Put it back the way it was.
credential.helper=store
Run Code Online (Sandbox Code Playgroud)
还值得注意的是,有一些方法可以完全避免这个问题,例如,您可以将~/.ssh/config's 与 Github 的关联 SSH 密钥(一个用于工作,一个用于娱乐)以及相应的自定义命名远程主机一起使用来解决身份验证上下文化问题。
这种方法对我有用,应该与操作系统无关。这有点笨手笨脚,但很快,让我重新输入凭据。
只需找到您希望为其重新输入凭据的远程别名。
$ git remote -v
origin https://bitbucket.org/org/~username/your-project.git (fetch)
origin https://bitbucket.org/org/~username/your-project.git (push)
Run Code Online (Sandbox Code Playgroud)
复制项目路径( https://bitbucket.org/org/~username/your-project.git)
然后取下遥控器
$ git remote remove origin
Run Code Online (Sandbox Code Playgroud)
然后加回来
$ git remote add origin https://bitbucket.org/org/~username/your-project.git
Run Code Online (Sandbox Code Playgroud)
小智 5
最终为我解决这个问题的是使用 GitHub 桌面,转到存储库设置,然后从存储库 url 中删除 user:pass@。然后,我尝试从命令行进行推送,并提示输入登录凭据。当我把它们放进去之后,一切都恢复正常了。Visual Studio 和命令行都可以运行,当然还有 GitHub 桌面。
GitHub Desktop->存储库->存储库设置->远程选项卡
将主远程存储库(来源)更改为:
https://pork@muffins@github.com/MyProject/MyProject.git
到:
https://github.com/MyProject/MyProject.git
点击“保存”
凭证将被清除。
至少在Windows上git remote show [remote-name]可以使用,例如
git remote show origin
Run Code Online (Sandbox Code Playgroud)
Update实际上useHttpPath是一个git 配置,它应该适用于所有 GCM。已更正。
原始问题的摘要
尽管标题说“删除凭据”,但描述让我假设您可能在 GitHub 上拥有多个帐户,例如与工作相关的帐户和私人项目的帐户。(至少那个问题让我找到了这个主题。)如果是这样,请继续阅读,否则,请忽略答案,但它可能在某些时候派上用场。
原因
Git 凭证管理器(简称 GCM),例如 Microsoft 的Windows GCM,默认情况下会存储每个主机的凭证。这可以通过检查 Windows 凭据管理器来验证(请参阅有关如何在英语、法语和德语 Windows 版本上访问它的其他答案)。因此,默认情况下不可能在同一主机(此处为 github.com)上使用多个帐户。
2020 年 10 月,GCM for Windows 被弃用并被GCM Core取代。此处的信息仍然适用于新的 GCM,它甚至应该使用 GCM for Windows 存储的凭据。
解决方案
配置 git以包含存储库的完整路径作为每个凭证条目的附加信息。还记录在GCM for Windows上。
我个人更喜欢包含 HTTP(S) [存储库] 路径,以便能够为每个存储库使用单独的帐户。
对于所有可能的主机:
git config --global credential.useHttpPath true
Run Code Online (Sandbox Code Playgroud)
仅适用于 github.com:
git config --global credential.github.com.useHttpPath true
Run Code Online (Sandbox Code Playgroud)
查看 GCM 和git文档,也许您想指定不同的内容。
请运行以下命令 -
git config --global credential.helper cache
Run Code Online (Sandbox Code Playgroud)
然后运行任何 git 命令,例如 git pull ,它会要求输入用户名和密码。输入详细信息,如果您想存储 git 凭据,请运行以下命令 -
git config --global credential.helper store
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
625315 次 |
| 最近记录: |