git 每次push都需要输入用户和密码

时间:2022-08-29 19:01:32
git remote -v
origin https://github.com/userName/xx.git (fetch)
origin https://github.com/userName/xx.git (push)

原因是使用了https/http的方式来push

1.移除原来的remote

git remote remove origin

2.创建新的remote

git remote add origin  git@github.com:userName/xx.git

3.再输入git remote -v ,发现remote改变了

git remote -v
origin git@github.com:userName/xx.git (fetch)
origin git@github.com:userName/xx.git (push)