Github不会缓存我的密码

时间:2018-01-23 05:35:49

标签: git macos github ssh keychain

最近,我在线更改了我唯一的Github帐户的密码。从那时起,每当我在本地机器上使用git做任何事情时,它都会一直询问我的用户名和密码。我看了How do I update the password for Git?https://help.github.com/articles/updating-your-github-access-credentials/

问题Git keeps prompting me for passwordgit: osxkeychain credential helper silently fails to remember username/password与我的相似,只是我没有使用SSH(或者如果git使用ssh我不知道它。我的.ssh目录中不包含任何关于Github的内容)。

我以前在Keychain应用程序中有一个github项目。由于事情不起作用,我选择删除 它,现在当我在某些github操作中输入我的用户名和密码时,没有自动创建新项目。

尝试git config --global credential.helper osxkeychain会产生以下错误

$ git config --global credential.helper osxkeychain
warning: credential.helper has multiple values
error: cannot overwrite multiple values with a single value
       Use a regexp, --add or --replace-all to change credential.helper.

以下是git config -l的输出:

git config -l
credential.helper=osxkeychain
user.name=ewan-delanoy
user.email=<my e-mail here>
push.default=simple
credential.helper=osxkeychain
credential.helper=osxkeychain
credential.helper=osxkeychain
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.ignorecase=true
core.precomposeunicode=true
remote.origin.url=https://github.com/ewan-delanoy/Ludlow-Street.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master

更新:根据当前回答的建议,我还提供git config -l --show-origin的输出:

file:/usr/local/git/etc/gitconfig   core.excludesfile=~/.gitignore
file:/usr/local/git/etc/gitconfig   core.legacyheaders=false
file:/usr/local/git/etc/gitconfig   core.quotepath=false
file:/usr/local/git/etc/gitconfig   mergetool.keepbackup=true
file:/usr/local/git/etc/gitconfig   push.default=simple
file:/usr/local/git/etc/gitconfig   color.ui=auto
file:/usr/local/git/etc/gitconfig   color.interactive=auto
file:/usr/local/git/etc/gitconfig   repack.usedeltabaseoffset=true
file:/usr/local/git/etc/gitconfig   alias.s=status
file:/usr/local/git/etc/gitconfig   alias.a=!git add . && git status
file:/usr/local/git/etc/gitconfig   alias.au=!git add -u . && git status
file:/usr/local/git/etc/gitconfig   alias.aa=!git add . && git add -u . && git status
file:/usr/local/git/etc/gitconfig   alias.c=commit
file:/usr/local/git/etc/gitconfig   alias.cm=commit -m
file:/usr/local/git/etc/gitconfig   alias.ca=commit --amend
file:/usr/local/git/etc/gitconfig   alias.ac=!git add . && git commit
file:/usr/local/git/etc/gitconfig   alias.acm=!git add . && git commit -m
file:/usr/local/git/etc/gitconfig   alias.l=log --graph --all --pretty=format:'%C(yellow)%h%C(cyan)%d%Creset %s %C(white)- %an, %ar%Creset'
file:/usr/local/git/etc/gitconfig   alias.ll=log --stat --abbrev-commit
file:/usr/local/git/etc/gitconfig   alias.lg=log --color --graph --pretty=format:'%C(bold white)%h%Creset -%C(bold green)%d%Creset %s %C(bold green)(%cr)%Creset %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
file:/usr/local/git/etc/gitconfig   alias.llg=log --color --graph --pretty=format:'%C(bold white)%H %d%Creset%n%s%n%+b%C(bold blue)%an <%ae>%Creset %C(bold green)%cr (%ci)' --abbrev-commit
file:/usr/local/git/etc/gitconfig   alias.d=diff
file:/usr/local/git/etc/gitconfig   alias.master=checkout master
file:/usr/local/git/etc/gitconfig   alias.spull=svn rebase
file:/usr/local/git/etc/gitconfig   alias.spush=svn dcommit
file:/usr/local/git/etc/gitconfig   alias.alias=!git config --list | grep 'alias\.' | sed 's/alias\.\([^=]*\)=\(.*\)/\1\     => \2/' | sort
file:/usr/local/git/etc/gitconfig   include.path=~/.gitcinclude
file:/usr/local/git/etc/gitconfig   include.path=.githubconfig
file:/usr/local/git/etc/gitconfig   include.path=.gitcredential
file:/usr/local/git/etc/gitconfig   diff.exif.textconv=exif
file:/usr/local/git/etc/gitconfig   credential.helper=osxkeychain
file:/Users/ewandelanoy/.gitconfig  user.name=ewan-delanoy
file:/Users/ewandelanoy/.gitconfig  user.email=<my e-mail here>
file:/Users/ewandelanoy/.gitconfig  push.default=simple
file:/Users/ewandelanoy/.gitconfig  credential.helper=osxkeychain
file:.git/config    core.repositoryformatversion=0
file:.git/config    core.filemode=true
file:.git/config    core.bare=false
file:.git/config    core.logallrefupdates=true
file:.git/config    core.ignorecase=true
file:.git/config    core.precomposeunicode=true
file:.git/config    remote.origin.url=https://github.com/ewan-delanoy/Ludlow-Street.git
file:.git/config    remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
file:.git/config    branch.master.remote=origin
file:.git/config    branch.master.merge=refs/heads/master

1 个答案:

答案 0 :(得分:1)

您只需编辑全局文件即可只留下一个条目:

git config --global --edit

同时检查 该设置的设置位置:

git config -l --show-origin

然后delete your old credentials stored in it
下一次推送将再次询问您的凭据,但会缓存它们。