您的位置:首页 > 理论基础 > 计算机网络

[git] https模式下,自动输入用户名和密码

2014-01-19 17:43 323 查看
如何让git 提交时,不输入用户名和密码?

按照git 的加key的说明:
https://help.github.com/articles/generating-ssh-keys
ssh-keygen -t rsa -C "your_email@example.com"
# Creates a new ssh key, using the provided email as a label
# Generating public/private rsa key pair.
# Enter file in which to save the key (/home/you/.ssh/id_rsa):
ssh-add id_rsa


sudo apt-get install xclip
# Downloads and installs xclip. If you don't have `apt-get`, you might need to use another installer (like `yum`)

xclip -sel clip < ~/.ssh/id_rsa.pub
# Copies the contents of the id_rsa.pub file to your clipboard


当仍然会要求输入用户名和密码,最后找到了临时解决方法:
https://help.github.com/articles/set-up-git


Username

First you need to tell git your name, so that it can properly label the commits you make.
git config --global user.name "Your Name Here"
# Sets the default name for git to use when you commit


Email

Git saves your email address into the commits you make. We use the email address to associate your commits with your GitHub account.
git config --global user.email "your_email@example.com"
# Sets the default email for git to use when you commit


Your email address for Git should be the same one associated with your GitHub account. If it is not, see this
guide for help adding additional emails to your GitHub account. If you want to keep your email address hidden, this
guide may be useful to you.

Overriding
settings in individual repos


Password
caching

The last option we need to set will tell git that you don't want to type your username and password every time you talk to a remote server.

Tip: You need git 1.7.10 or
newer to use the credential helper

To use this option, you need to turn on the credential helper so that git will save your password in memory for some time:
git config --global credential.helper cache
# Set git to use the credential memory cache


By default git will cache your password for 15 minutes. You can change this if you like.
git config --global credential.helper 'cache --timeout=3600'
# Set the cache to timeout after 1 hour (setting is in seconds)


Tip: The credential helper only works when you clone an HTTPS repository
URL. If you use the SSH repository URL instead, SSH keys are used for authentication. This
guide offers help generating and using an SSH key pair.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: