我正在使用几个存储库,但最近我只在我们的内部存储库中工作,一切都很好。

今天我不得不提交并将代码推到另一个,但我遇到了一些麻烦。

$ 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'

为了避免凭证缓存…

似乎什么都不管用;谁有更好的主意?


当前回答

最终为我解决这个问题的是使用GitHub桌面,进入存储库设置,并从存储库url中删除user:pass@。然后,我尝试从命令行推送,并提示输入登录凭据。我把它们放进去之后,一切都恢复正常了。Visual Studio和命令行都可以工作,当然还有GitHub桌面。

GitHub Desktop->Repository->Repository Settings->Remote选项卡

将主远程存储库(origin)更改为:

https://pork@muffins@github.com/MyProject/MyProject.git

To:

https://github.com/MyProject/MyProject.git

点击“保存”

凭证将被清除。

其他回答

需要登录各自的github用户名和密码

清除windows下的用户名和密码

控制面板\用户帐户\凭证管理器

编辑windows凭证

删除现有用户,现在转到命令提示符写入推送命令,它会显示一个github弹出输入用户名/电子邮件和密码。

现在我们可以在切换用户后推送代码。

最终为我解决这个问题的是使用GitHub桌面,进入存储库设置,并从存储库url中删除user:pass@。然后,我尝试从命令行推送,并提示输入登录凭据。我把它们放进去之后,一切都恢复正常了。Visual Studio和命令行都可以工作,当然还有GitHub桌面。

GitHub Desktop->Repository->Repository Settings->Remote选项卡

将主远程存储库(origin)更改为:

https://pork@muffins@github.com/MyProject/MyProject.git

To:

https://github.com/MyProject/MyProject.git

点击“保存”

凭证将被清除。

根据@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配置凭据。helper返回Manager - Core(来自跨平台GCM - Git Credential Manager Core项目),你可以:

保持这个设置不变 使用跨平台GCM命令删除您的凭证: printf "Host=github.com\nusername=xxx\nprotocol=https" | \ Git证书管理器核心擦除

检查它是否被带走:

  printf "Host=github.com\nusername=xxx\nprotocol=https" | \
    git credential-manager-core get

(用你的GitHub用户名替换xxx) (将github.com替换为实际的远程Git存储库托管服务器:gitlab.com, bitbucket.com, yourOwnServer.com)

如果您看到提示您的凭据,单击“取消”:之前的凭据已从操作系统底层机密管理器(Windows凭据管理器,Linux libsecret或Mac osxkeychain)中消失)

在下一次git推送时,通过GCM-core凭据助手输入您的凭据作为提示符:您的新凭据将被存储。

尝试使用下面的命令。

git credential-manager

在这里,您可以获得各种选项来管理您的凭证(检查下面的屏幕)。

或者你甚至可以直接尝试这个命令:

git credential-manager uninstall

这将在每次服务器交互请求时再次提示输入密码。