我正在使用几个存储库,但最近我只在我们的内部存储库中工作,一切都很好。
今天我不得不提交并将代码推到另一个,但我遇到了一些麻烦。
$ 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
没有什么我能做的,这将再次带来密码输入。
我如何重置系统上的凭据,以便Git询问我该存储库的密码?
我试过:
Git配置——global——unset core.askpass
以便取消设置密码
Git配置凭证。Helper '缓存超时=1'
为了避免凭证缓存…
似乎什么都不管用;谁有更好的主意?
根据@patthoyts的高票数回答:
他的回答使用但没有解释本地、全局和系统配置。官方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
同样值得注意的是,有一些方法可以完全避免这个问题,例如,您可以使用~/。ssh/config与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)
复制项目路径(https://bitbucket.org/org/~username/your-project.git)
然后取下遥控器
$ git remote remove origin
然后再加回去
$ git remote add origin https://bitbucket.org/org/~username/your-project.git
Git凭据缓存运行一个守护进程,该进程将您的凭据缓存到内存中,并根据需要分发它们。因此,如果您继续使用git-credential-cache- daemon作为缓存,那么终止git-credential-cache- daemon进程将丢弃所有这些,并导致重新提示您输入密码。辅助选项。
你也可以使用Git config——global——unset credential.helper禁用Git凭据缓存。然后重新设置,您将继续拥有缓存的凭据,可用于其他存储库(如果有的话)。你可能还需要执行git config——system——unset credential命令。如果在系统配置文件(例如,Windows 2的Git)中已经设置了helper。
On Windows you might be better off using the manager helper (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 manager helper included in Git for Windows 2.x has replaced the earlier wincred helper that was added in Git for Windows 1.8.1.1. A similar helper called winstore is also available online and was used with GitExtensions as it offers a more GUI driven interface. The manager helper offers the same GUI interface as winstore.
从Windows 10支持页面提取详细的Windows凭据管理器:
要打开凭据管理器,请在任务栏上的搜索框中输入“凭据管理器”,然后选择凭据管理器控制面板。
然后选择Windows凭证来编辑(=删除或修改)存储的给定URL的git凭证。