Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows 从Git中删除凭据_Windows_Git_Credentials - Fatal编程技术网

Windows 从Git中删除凭据

Windows 从Git中删除凭据,windows,git,credentials,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 reque

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

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

$ 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 config--global--unset core.askpass
要取消设置密码

  • git config credential.helper'cache--timeout=1'
为了避免凭据缓存


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

Git凭据缓存运行一个守护进程,将您的凭据缓存在内存中,并按需分发。所以,如果您继续将其用作cache.helper选项,那么杀死您的git凭证缓存——守护进程会丢弃所有这些,并导致重新提示您输入密码

您还可以使用
Git config--global--unset credential.helper
禁用Git凭证缓存的使用。然后重置此项,您将继续为其他存储库(如果有)提供缓存凭据。如果在系统配置文件(例如,git for Windows 2)中设置了此项,则可能还需要执行
git config--system--unset credential.helper

在Windows上,您最好使用manager助手(
git config--global credential.helper manager
)。这会将您的凭据存储在Windows凭据存储中,该存储具有控制面板界面,您可以在其中删除或编辑存储的凭据。使用此存储,您的详细信息将由您的Windows登录进行保护,并且可以在多个会话中保持。Git for Windows 2.x中包含的管理器帮助程序已替换了Git for Windows 1.8.1.1中添加的早期wincred帮助程序。类似的名为winstore的助手也可以在线使用,并与GitExtensions一起使用,因为它提供了更为GUI驱动的界面。manager助手提供与winstore相同的GUI界面

从Windows凭据管理器的详细信息中提取:

要打开凭证管理器,请在任务栏上的搜索框中键入“凭证管理器”,然后选择凭证管理器控制面板


然后选择Windows凭据编辑(=删除或修改)给定URL存储的git凭据。

从位于Windows当前登录用户文件夹中的.gitconfig文件中删除此行:

[credential]
helper = !\"C:/Program Files (x86)/GitExtensions/GitCredentialWinStore/git-credential-winstore.exe\"
这对我很有效,现在当我按下遥控器时,它会再次询问我的密码。

重新键入:

$ git config credential.helper store
然后,系统会提示您再次输入凭据

警告

使用此帮助程序将未加密的密码存储在磁盘上


来源:

我发现了一些适合我的东西。当我将我的评论写到OP时,我未能检查系统配置文件:

git config --system -l
显示

credential.helper=!github --credentials
线路。我把它弄得乱七八糟

git config --system --unset credential.helper

现在凭证被忘记了。

在我们的例子中,清除用户的.git凭证文件中的密码对我们很有效

c:\users\[username]\.git-credentials

您可以删除行
credential.helper=!github--凭据
来自以下文件
C:\Program Files\Git\mingw64\etc\gitconfig
要删除Git的凭据

请尝试使用以下命令

git credential-manager
在这里,您可以获得各种选项来管理您的凭据(检查下面的屏幕)

或者您甚至可以直接尝试此命令:

git credential-manager uninstall

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

我遇到了与OP相同的问题。它将我的旧Git凭据存储在系统的某个地方,我想将Git与我的新凭据一起使用,因此我运行了命令

$ git config --system --list
它表明

credential.helper=manager
每当我执行
gitpush
时,都会使用我的旧用户名,我很早就设置了这个用户名,我想使用一个新的GitHub帐户来推动更改。我后来发现我的旧GitHub帐户凭据存储在 控制面板→ 用户帐户→ 凭证管理器→ 管理Windows凭据

$ git remote -v 
origin  https://bitbucket.org/org/~username/your-project.git (fetch)
origin  https://bitbucket.org/org/~username/your-project.git (push)


我刚刚删除了这些凭据,当我执行
git push时,它要求我提供GitHub凭据,效果非常好。

如果此问题出现在Windows计算机上,请执行以下操作

  • 转到凭据管理器

    • 在德语中,它被称为:Anmeldeinformationsverwaltung
    • 在法语中,它被称为:Gestionnaire d'identification
    • 在波兰语中,它被称为:Menedżer poświadczen
    • 在葡萄牙语中,它被称为:Gerenciador de Credenciais
    • 在俄语中,它被称为:чччччччччч

  • 转到Windows凭据

  • 删除通用凭据下的条目

  • 请尝试再次连接。这一次,它应该提示您输入正确的用户名和密码


在带有“wincred”*的Windows 2003服务器中,其他答案对我都没有帮助。我不得不使用

  • cmdkey/list
    列出所有存储的凭据
  • cmdkey/delete:Target
    删除具有“Target”名称的凭证


(*我所说的“wincred”是指git config--global credential.helper wincred

在我的例子中,我找不到保存在Windows凭据管理器(Windows 7)中的凭据

我可以通过执行

git config --global credential.helper wincred

老实说,这是一个万幸,看看它是否会抹去我的证书,它实际上起了作用

在我的例子中,Git使用Windows存储凭据

$ git remote -v 
origin  https://bitbucket.org/org/~username/your-project.git (fetch)
origin  https://bitbucket.org/org/~username/your-project.git (push)
您只需删除Windows帐户中存储的凭据:

将显示
credential.helper=manager
(这是在windows计算机上)

为您禁用此缓存的用户名/密码
git credential-manager clear
git config --global credential.helper
→ manager
git config --list
git config --system --unset credential.helper
$ 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
git remote show origin
git config credential.helper 'cache --timeout=30'
git credential-cache exit
entries=`cmdkey.exe /list: | grep git | sed -r -e 's/^[^:]+:\s*(.*)$/\1/gm'`
for entry in ${entries}
do
    cmdkey.exe "/delete:${entry}"
    cmdkey.exe "/generic:${entry}" "/user:${GIT_USERNAME}" "/pass:${GIT_PASSWORD}"
done
$ echo "url=https://appharbor.com" | git credential reject
$ git credential reject
protocol=https
host=gitlab.com
username=me@example.com
↵
$ git remote -v 
origin  https://bitbucket.org/org/~username/your-project.git (fetch)
origin  https://bitbucket.org/org/~username/your-project.git (push)
$ git remote remove origin
$ git remote add origin https://bitbucket.org/org/~username/your-project.git