经过以上的培训,同学们肯定对git的基本使用没有什么问题了。但是每次代码有更改后,依旧需要
git add *
git commit * git 打开vim编辑器,编辑提交信息
或者 git commit * -m "提交信息“
git push 时,需要输入用户名和密码
可以有两种解决方法:
一、生成ssh key,过程如下:
$ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/home/munication/.ssh/id_rsa): 直接按下回车,Created directory '/home/munication/.ssh'. 将key保存到默认的位置Enter passphrase (empty for no passphrase): 输入自己的密码例如lisanEnter same passphrase again: 重复输入刚才一样的密码Your identification has been saved in /home/munication/.ssh/id_rsa. Your public key has been saved in /home/munication/.ssh/id_rsa.pub. The key fingerprint is: SHA256:CfxwbPFh45ZCG/qixBUxqXwOlD1Gedk9RAqIZAIXYZQ munication@develop The key's randomart image is: +---[RSA 3072]----+ |.oB=o====o++o | | oEo+.B*oO.=o | | o o*o* * . | | .+..B + | | o+. S | | . ... | | . | | | | | +----[SHA256]-----+二、将ssh key添加到github上,到 https://github.com/settings/keys中SSH and GPG keys中的new SSH key按钮,将
'/home/munication/.ssh'中的有pub字样的文件内容,粘贴保存即可。三、 设置ssh key后push为什么还要输入用户名和密码
因为你用的是https而不是ssh。 你可以更新一下origin
git remote remove origin git remote add origin git@github.com:guochaoxxl/18DataStruct.git
之后你还需要重新设置分支,比如:
git push --set-upstream origin master四、设置下提交,这次不需要密码了,也不需要用户名了。五、其实使用GPG key是差不多一样的步骤。不再多说了。