赞
踩
出现以上情况的主要原因在于采用的是 https 方式提交代码, 如果采用的是 ssh 方式只需要在版本库中添加用户的 sha 的key就可以实现提交时无需输入用户名和密码。
- git remote rm origin
- git remote add origin git@github.com:(用户名)/版本库名
其中git remote add origin 【】,括号内的内容按下述方式获取。
- The authenticity of host 'github.com (192.30.252.131)' can't be established.
- RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
- Are you sure you want to continue connecting (yes/no)? yes
- Warning: Permanently added 'github.com,192.30.252.131' (RSA) to the list of known h osts.
- Permission denied (publickey).
- fatal: Could not read from remote repository.
- Please make sure you have the correct access rights
此时只需执行以下命令生成自己本地的RSA的key即可。
ssh-keygen -t rsa -C "用户名"
执行过程中系统会提示一些内容,无需管理,直接enter即可。
最终在终端会输出以下命令:
- Your identification has been saved in /c/Users/AlexYi/.ssh/id_rsa.
- Your public key has been saved in /c/Users/AlexYi/.ssh/id_rsa.pub.
- The key fingerprint is:
- SHA256:rxfK05d7oZWpDvQ5dRQM0Na7...
- The key's randomart image is:
- +---[RSA 2048]----+
- | .o.+. |
- | o o.|
- | . o|
- | o |
- ...
按照命令路径提示找到对应的 id_rsa.pub 文件并使用记事本打开文件,可以看到以ssh-rsa开头的命令代码如下,复制代码:
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQD61q7klioPbE40aueZd55i1Cexow
EOKdJZOtiwxIqy4O+61LLGsfsUrLPC4Fr1zjq1QlLo92I4uZt+8Z8qkyY1DAr5g/mTV89
KGAsnjIyka5vcL7QuBslTbpjPASp/xxp2C47oQ7+beLSsadiTfS0iFSzhzbkAciS9cc3TT/
GEBxLpJfhMXGVcO6RUBnV7MCVwySRBGfxXIzwUG7RFQ0UM8+xWSXHxYwXn
CLLZBxS0WG0QULjBtIy711Rf6k5SQOQSlrz+X3DgZ7OIBXA5w7rA7v2gR2mfEI/jikldF
5FjNYt5vyQD+6o6zk41HLX5i2kZGPCweKv4FDbztqKSogPsgR15DkKBhm8ZaVai00x
5BjI5P1b/DW6KI55beKGozQ6peXJgXTPqUbrGC4ythmpGcLbJDm95Onn+Evf/0IlsGm
hqy7QWqbfeaSvVT58w/ASJZbHAt7r+QBMqw5hui3rzy7Dha9RSUYTFPCg/eYcn7jW6X
HfHld12YJVO6TD5MUM= weitao.wang
此时使用git push -u origin master就可以成功提交代码到Github仓库,并且不需要每次都输入用户名、密码。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。