创建Git密钥:
1、生成密钥:
右键–>Git Bash Here:先输入ssh-keygen –t rsa –C "邮箱地址",注意ssh-keygen之间是没有空格的,其他的之间是有空格的,邮箱地址是咱们在注册GitHub的时候用的邮箱。
生成的密钥在这里:C:\Users\Administrator\.ssh
2、将id_rsa.pub用记事本打开,复制里面全部的内容,放在GitHub的SSH Keys上:
右上头像箭头->Settings->左侧SSH and GPG keys,New SSH key,粘贴,Add GPG key
3、ssh –T [email protected] 验证设置是否成功:
[email protected] MINGW64 /githere
$ ssh -T [email protected]
The authenticity of host ‘github.com (13.250.177.223)‘ can‘t be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes
这里回复一个yes,而!不!是!习!惯!性!回!车!!
Warning: Permanently added ‘github.com,13.250.177.223‘ (RSA) to the list of known hosts.
Hi Xiaobai0419! You‘ve successfully authenticated, but GitHub does not provide shell access.
这时是在c盘.ssh目录下多生成了一个known_host文件,再次尝试命令,成功:
[email protected] MINGW64 /githere
$ ssh -T [email protected]
Hi Xiaobai0419! You‘ve successfully authenticated, but GitHub does not provide shell access.
提交项目:
1、切换到项目根目录,创建本地仓库(.git隐藏目录中写入信息,如果此前有这个目录,需先整个删除):
$ git init
2、将目录下所有文件添加到本地仓库:
$ git add .
3、提交到本地仓库,添加注释:
$ git commit -m ‘dubbo first commit‘
4、添加远程仓库地址(需要先在GitHub上建好,复制地址到这里),命名为origin:
$ git remote add origin https://github.com/Xiaobai0419/minexiaobai0419.git
5、推传到远程仓库:
$ git push -u origin master
Username for ‘https://github.com‘: Xiaobai0419
需要输入GitHub注册的用户名、密码后确认
6、如果项目已存在于远程仓库,要先pull更新,尤其是有在其他点推传更新的时候:
$ git pull --rebase origin master
7、此后可直接在配置了同一个Git.exe的IDEA中添加、提交、push到远程仓库。
原文地址:https://www.cnblogs.com/free-wings/p/9715280.html