使用命令
在git bash 中执行
设置记住密码(默认15分钟):
>git config –global credential.helper cache
如果想自己设置时间,可以这样做:
>git config credential.helper ‘cache –timeout=3600’
这样就设置一个小时之后失效
长期存储密码:
>git config –global credential.helper store
>>>使用ssh方式(推荐)
>>>1、在每次push 的时候,都要输入用户名和密码,是不是很麻烦?原因是使用了https方式 push,在git bash里边输入 git remote -v
>>>
>$ git remote rm origin //删除http
$ git remote add origin git@github.com:sosout/myblog.git //添加shh
$ git push origin //执行你的更改
>>>>1 2 3
>>>>再次执行 git remote -v 查看是否更新成功(对比第一次执行)
>>>>
>ssh-keygen -t rsa -C “email”
添加你的SSH公钥(email是你github注册账号的邮箱)
>>>>>1 2
>>>>>第一次出现:Enter file in which to save the key (/root/.ssh/id_rsa): 直接按回车就行
>>>>>第二次出现:Enter passphrase (empty for no passphrase): 第一次输入公钥密码(推荐不用输入,直接回车,以便在clone、pull、push等不用输入公钥密码)
>>>>>第三次出现:Enter same passphrase again: 再次输入公钥密码
>>>>>公钥创建成功,位置在你使用 git bush 的当前项目目录下(xx.pub)
>>>>>公钥和私钥配对,接下来去C盘找你的私钥
>>>>>私钥一般在你的用户文件夹的 .ssh下,打开xx.pub,复制内容,在github中创建ssh keys (没有私钥,百度)
>>>>>接下来 push 就不需要密码了
>>>>>如果你遇到以下问题,请仔细查看自己的公钥和私钥有没有分清
>>>>>
>Permission denied (publickey).
fatal: The remote end hung up unexpectedly.
Permission denied (publickey).
fatal: Could not read from remote repository.
>>>>>>1 2 3 4 5
>>>>>>ssh机制,简单的说,要使本地主机和远程服务器通过ssh连接,需要一对密钥,一个是私钥,存在于本地主
机,另一个是公钥,放在远程服务器。
>>>>>>初学者常用指令(如果需要高端的,自己去百度,一大堆)
>>>>>>同步github的项目到本地(前提是你的github上已有仓库,怎么在github上创建仓库new repository)
>>>>>>
>git clone git@github.com:512439130/512439130.github.io.git (http,在你的download下复制)
git clone https://github.com/512439130/512439130.github.io.git (ssh,同理)
//将工作文件修改提交到本地暂存区
git add <文件名.后缀>
git add . //当前仓库下所有更新的文件
//删除本地,并将任务提交到缓存区
git rm <文件名.后缀>
//查看项目状态(未提交)
git status
//准备提交
git commit -m "更新记录(此处随便写,就是记录你更新的日志)"
//正式提交
git push
//查看更新日志
git log
//更新远程仓库到本地
git pull