注:来源https://www.liaoxuefeng.com/
将本地文件上传至github
1.首先将文件上传至本地仓库(add+commit)后,生成ssh密钥
$ ssh-keygen -t rsa -C "1477374613@qq.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/shazx/.ssh/id_rsa): //enter,密钥文件就在.ssh下面,也就是.hub的内容
Created directory '/c/Users/shazx/.ssh'.
Enter passphrase (empty for no passphrase): //enter
Enter same passphrase again: //enter
Your identification has been saved in /c/Users/shazx/.ssh/id_rsa.
Your public key has been saved in /c/Users/shazx/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:ovAE1zwT25sZszRjtRAvdwHb6X7pE5oVPuTGQUw4qE8 1477374613@qq.com
The key's randomart image is:
+---[RSA 2048]----+
| . o.oo.+. |
| o + +.+ooo |
| . . * X.= +o |
| o =.%Eo + |
| . . . So .= o |
| + . . .. O. |
| o .=oo |
| oo. |
| .. |
+----[SHA256]-----+
2 点击头像新建ssh密钥,将pub中的密钥复制上去
3 首先是添加新的远程仓库
$ git remote add origin https://github.com/zxjwd/tc.git //后面的地址为SSH的https
然后对远程仓库提交
$ git push origin master
fatal: HttpRequestException encountered.
▒▒▒▒▒▒▒▒ʱ▒▒▒▒
Username for 'https://github.com': zx
Counting objects: 9, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (9/9), 759 bytes | 151.00 KiB/s, done.
Total 9 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), done.
To https://github.com/zxjwd/tc.git
* [new branch] master -> master
通过SSH clone项目
新建一个空的文件夹,使用 Git bash
找到所需项目,点击clone会有ssh
$ git clone git@github.com:FreeApophis/TrueCrypt.git 后面就是项目的ssh地址
Cloning into 'TrueCrypt'...
Warning: Permanently added the RSA host key for IP address '52.74.223.119' to the list of known hosts.
remote: Enumerating objects: 5129, done.
Receiving objects: 20% (1050/5129), 4.76 MiB | 25.00 KiB/s