【发布时间】:2013-08-02 01:31:34
【问题描述】:
我是使用 github 的新手,但我成功地提交并提取了一些代码,然后在进行更改后将其推回存储库。但是,当我在 github 上推送或拉取时,我每次都需要输入我的用户名和密码。有没有办法一次保存这些凭据而不再被询问? 我正在使用 Aptana Studio 3,构建:3.4.1.201306062137 和 ubuntu 12.04
【问题讨论】:
我是使用 github 的新手,但我成功地提交并提取了一些代码,然后在进行更改后将其推回存储库。但是,当我在 github 上推送或拉取时,我每次都需要输入我的用户名和密码。有没有办法一次保存这些凭据而不再被询问? 我正在使用 Aptana Studio 3,构建:3.4.1.201306062137 和 ubuntu 12.04
【问题讨论】:
首先你需要告诉 git 你的名字,这样它才能正确地标记你所做的提交。
$git config --global user.name "Your Name Here"
# Sets the default name for git to use when you commit
Git 将您的电子邮件地址保存到您所做的提交中。我们使用电子邮件地址将您的提交与您的 GitHub 帐户相关联。
$git config --global user.email "your_email@example.com"
# Sets the default email for git to use when you commit
您的 Git 电子邮件地址应与您的 GitHub 帐户关联的电子邮件地址相同。
我们需要设置的最后一个选项会告诉 git,你不想在每次与远程服务器通信时都输入用户名和密码。
$git credential-osxkeychain
# Test for the cred helper
# Usage: git credential-osxkeychain <get|store|erase>
要告诉 git 使用 osxkeychain,只需设置全局 git 配置:
$git config --global credential.helper osxkeychain
# Set git to use the osxkeychain credential helper
下次克隆需要密码的 HTTPS URL 时,系统会提示您输入用户名和密码,并授予对 OSX 钥匙串的访问权限。完成此操作后,用户名和密码将存储在您的钥匙串中,您无需再次将它们输入到 git。
希望这会有所帮助:/
【讨论】:
$curl -s -O \ http://github-media-downloads.s3.amazonaws.com/osx/git-credential-osxkeychain # Download the helper chmod u+x git-credential-osxkeychain # Fix the permissions on the file so it can be run
这将在 linux 上完成工作:
$ git config credential.helper store
【讨论】: