/*目录*/

本地push到github时,每次都要输入用户名和密码的问题

在github.com上 建立了一个小项目,可是在每次push 的时候,都要输入用户名和密码,很麻烦。

原因

原因是使用了https方式 push 

这种方式产生的原因,一般是我们clone时一定是使用了http的方式 ,例如我们在github上创建了一个项目,然后我们clone到本地时使用了http而非git 

 

我们可以看到下方的项目地址,默认是http的,clone时:

git clone https://github.com/gatieme/AderSCloud.git

如果使用ssh的话,应该使用的路径是:

git clone git://github.com/gatieme/AderSCloud.git

 解决方法:

 在bash行输入

xujin@MINGW64 /d/学习/test1 (master)
$ git remote -v
origin  https://github.com/xujinting/test1.git (fetch)
origin  https://github.com/xujinting/test1.git (push)

下面把它换成ssh方式的。 
移出旧的http的origin

xujin@ʥ▒▒ MINGW64 /d/学习/test1 (master)
$ git remote -v

xujin@ʥ▒▒ MINGW64 /d/学习/test1 (master)
$ git remote add origin git@github.com:gatieme/AderSCloud.git  #添加新的git方式的origin 

xujin@ʥ▒▒ MINGW64 /d/学习/test1 (master)
$ git remote -v
origin  git@github.com:gatieme/AderSCloud.git (fetch)
origin  git@github.com:gatieme/AderSCloud.git (push)

 

posted @ 2020-07-01 14:47  嘟嘟噜~  阅读(213)  评论(0)    收藏  举报