2013-04-17 20 views
29

我需要禁用凭据帮手OS X:git credential-osxkeychain禁用混帐凭据osxkeychain

它被禁用在全局配置文件,并在当地的一个,其实它有从未启用本。不过,它会记住我的github登录信息。
我在笔记本电脑上,所以我不想自动无密码地访问我的回购。
使用ssh密钥。这是一台新电脑,整个系统设置仍在进行中。
现在我使用的https回购裁判和证书助手一直在踢

这是我的conf文件:


git config --edit =>

[core] 
    repositoryformatversion = 0 
    filemode = true 
    bare = false 
    logallrefupdates = true 
    ignorecase = true 
    precomposeunicode = false 
[remote "origin"] 
    url = https://github.com/user/repo.git 
    fetch = +refs/heads/*:refs/remotes/origin/* 
[branch "master"] 
    remote = origin 
    merge = refs/heads/master 
[branch "develop"] 
    remote = origin 
    merge = refs/heads/develop 
[branch "deploy"] 
    remote = origin 
    merge = refs/heads/deploy 

git config --global --edit =>

[user] 
    email = **************** 
    name = tom 
[color] 
    ui = true 
[core] 
    editor = subl -w 
[github] 
    user = tompave 
[merge] 
    conflictstyle = diff3 
[push] 
    default = simple 

另外,运行git config --global credential.helper什么也没有返回(没错)。

但是,运行git config credential.helper返回osxkeychain

这怎么可能?我无法在本地配置文件中看到它,它在哪里设置?

我试图在本地设置它,看看会发生什么,它确实出现在repodir/.git/config。然后我删除了条目......但帮手仍然在这里并且很活跃。

我可以清楚地看到它在OS X钥匙串中的输入。
我可以删除它,然后git将再次要求输入密码...但只要我输入密码(例如,对于git fetch),钥匙串中的输入被恢复。

回答

57

为了帮助追踪设置,我会尝试使用:

git config --local credential.helper 
git config --global credential.helper 
git config --system credential.helper 

第一个检查本地回购的配置,第二个是你的~/.gitconfig,第三个是基于安装在那里的git 。根据其中一回来显示证书助手,你可以尝试使用等效--unset选项:如果您没有适当的权限

git config --local --unset credential.helper 
git config --global --unset credential.helper 
git config --system --unset credential.helper 

最后一个可能无法正常工作。因此,您可能需要运行sudo下的最后一个才能正常工作。 FWIW,您可能已经为Mac OS X的预建git图像安装了。如果您购买了/usr/local/git/etc/gitconfig,您会发现它确实为您设置了凭证助手。所以上面的最后一条命令可以帮助解决这个问题。

+0

听起来类似于我的答案,但更实际的comamnds,所以+1。 – VonC

+0

谢谢。错误地解释了输出,因为我认为'git config'认为本地选项...并且不知道'--system'。现在命令'git config --system --edit'清楚地显示了osxkeychain选项,我可以取消它的设置,从输出来看,它看起来像'git config --edit'被默认启用'--local'选项解释。 – tompave

+0

一个光秃秃的'git config'不会*看*所有,但是当你改变一个时,一个纯粹的'git config'将会用于本地的git config。当你想编辑除本地git以外的东西时,你确实需要'--global'或'--system'之一config。 – jszakmeister

1

配置本身(git config --unset credential.helper)是不够的。
确保杀掉任何git-credential-osxkeychain进程(如described here),或者查看重新启动后问题是否仍然存在。

另外,当使用GitHub for Mac时,请检查是否存在该工具内部使用的配置。
请记住,仅git config将检查系统,全局和本地配置文件。

注意:使用git 2.9,您可以简单地将credential.helper设置为“空字符串”以禁用它:请参阅“How do I disable git's credential helper for a single repository?”。

+0

我想你错过了VonC的东西。你的链接不会去任何地方。 :-( – jszakmeister

+0

@jszakmeister链接固定 – VonC

+0

谢谢,我的坏,我认为'git config'会检查本地的一个... – tompave

16

其他答案是非常有帮助的。 credential.helper没有在任何列表中显示(指定--local,--global等),它总是显示在'git config -l'上。使用--show-origin命令显示它来自OS X特定文件。

$ git config --show-origin --get credential.helper 
file:/Applications/Xcode.app/Contents/Developer/usr/share/git-core/gitconfig osxkeychain 
+0

感谢您为'--show-origin'。我必须使用'git config --list --show-origin'来查看osxkeychain助手被引用的位置并更改该配置。 – luk2302

+0

那么如何禁用那里的钥匙串呢? –

+1

@ A.Lau使用'sudo vi WhatEverLocationIsShownAfter“file:”'并删除设置凭证助手的行。 – luk2302