解决Github push时总要求输入username 和password问题,记录备忘

最近开始使用Github了,但是有个问题:
每次git push origin master的时候,会要求输入username和password,
为了解决这个问题,网上搜了下解决方法。采纳了这篇博文中方法
在repository中有个.git 目录,目录里面有个config文件,文件内容大抵是这样的

[core]
repositoryformatversion = 0
filemode = true ….
[remote “origin”]
url = https://github.com/username/repo.git
fetch = +refs/heads/:refs/remotes/origin/

之所以每次都要求输入username和password是url中使用的方式是htttps方式,而不是ssh
为了避免输入username和password,可以简单的将

url = [email protected]:username/repo.git

这样每次git操作都是通过ssh认证的,不仅安全而且还很简便。
至于ssh认证,参见Github Helps。

你可能感兴趣的:(解决Github push时总要求输入username 和password问题,记录备忘)