Git使用疑问

Posted on 2020-03-14 18:16  FLGB  阅读(139)  评论(0编辑  收藏  举报

1.git操作是出现Username for 'https://github.com':的验证问题

Username for 'https://github.com': 输入的是github上的邮箱账号, 而不是github中设置的username, 这是个巨坑!!!
flrainy@163.com
Password for 'https://你的github邮箱@github.com': 输入github的登录密码,点击enter键即可.

2.问题:在github.com上 建立一个项目,可是在每次push 的时候,都要输入用户名和密码(问题一)

原因是使用了https方式 push 

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


我们可以看到右端的项目地址,默认是http的,clone时

1.git clone https://github.com/FLGBetter/MiniSpring.git 

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

git clone git://github.com/FLGBetter/MiniSpring.git 

解决

在termail里边 输入

$ git remote -v
origin https://github.com/FLGBetter/MiniSpring.git (fetch)
origin https://github.com/FLGBetter/MiniSpring.git (push)

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

git remote rm origin
1
添加新的git方式的origin
git remote add origin git@github.com:FLGBetter/MiniSpring.git

我们在查看一下push方式

git remote -v

再次push一下,已经不需要输入用户名密码了
git push origin

 

Copyright © 2024 FLGB
Powered by .NET 8.0 on Kubernetes