GIT:任何设置默认登录凭据的方法?

Kir*_*eck 11 git

我正在使用终端为mac并运行该线路

git push origin master
Run Code Online (Sandbox Code Playgroud)

它每次都要求我输入我的github.com用户名和密码,
有没有办法让它自动使用我的凭据?


我一直在收到错误

error: The requested URL returned error: 403 while accessing 
https://github.com/atheycreek/churchdeploy.git/info/refs
Run Code Online (Sandbox Code Playgroud)
[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = https://github.com/atheycreek/churchdeploy.git
Run Code Online (Sandbox Code Playgroud)

所以我改成了

[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = git:github.com/atheycreek/churchdeploy.git
Run Code Online (Sandbox Code Playgroud)

现在我得到..

kirkstrobeck:churchdeploy kirkstrobeck$ git push origin master
ssh: Could not resolve hostname git: nodename nor servname provided, or not known
fatal: The remote end hung up unexpectedly
Run Code Online (Sandbox Code Playgroud)

我改成了

[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = git@github.com/atheycreek/churchdeploy.git
Run Code Online (Sandbox Code Playgroud)

现在我得到..

kirkstrobeck:churchdeploy kirkstrobeck$ git push origin master
fatal: 'git@github.com/atheycreek/churchdeploy.git' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
Run Code Online (Sandbox Code Playgroud)

Col*_*n R 16

根据你对事物的描述,听起来你的[Project Dir]/.git/config文件是用行设置的url = https...,而不是url = git@github.com....你能检查一下这个文件,看看它的内容吗?如果您可以发布整个"远程起源"部分,那就太棒了.它可能看起来像这样:

[remote "origin"]
    url = https://github.com/atheycreek/churchdeploy.git
    fetch = +refs/heads/*:refs/remotes/origin/*
Run Code Online (Sandbox Code Playgroud)

但需要使用ssh而不是像这样的http:

[remote "origin"]
    url = git@github.com:atheycreek/churchdeploy.git
    fetch = +refs/heads/*:refs/remotes/origin/*
Run Code Online (Sandbox Code Playgroud)


man*_*lds 10

使用空密码短语适当地设置您的ssh密钥,您无需输入凭据:http://help.github.com/mac-set-up-git/


Sea*_*ean 5

如果在OSX上,您应该能够使用osxkeychain助手.您可以通过键入以下内容来检查是否已安装它:

git credential-osxkeychain
Run Code Online (Sandbox Code Playgroud)

如果您收到一条消息,指出这不是有效的git命令,您可以通过执行以下操作来安装它:

curl -s -O http://github-media-downloads.s3.amazonaws.com/osx/git-credential-osxkeychain
chmod u+x git-credential-osxkeychain
sudo mv git-credential-osxkeychain `dirname \`which git\``
Run Code Online (Sandbox Code Playgroud)

然后告诉git使用它:

git config --global credential.helper osxkeychain
Run Code Online (Sandbox Code Playgroud)

下次执行拉/推时,系统会要求您再次提供凭据.从那时起,git应该记住你的信息.