1.添加远程仓库,名称为origin
[root@kht130 kht]# git remote add origin git@github.com:zhkht/test.git
2.查看远程仓库的名称
[root@kht130 kht]# git remote
origin
3.生成SSH秘钥(一直回车):
[root@kht130 kht]# ssh-keygen -t rsa
4.查看生成的秘钥:
[root@kht130 kht]# cat /root/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCj/yrt9q4qRxa9xFowMai6fOECar5tCJ+C72TByS1AfJn9WIq+armTlkHI2mUltwdunhnG8FkE8ECnSjAcMIdibzPJuK5rW0oDzVDAmiYp5T7vdwGHBFGNwwmxR8b2AzdHJdZRJv9r2zWSlGl9Msl8bBWj5W3HdVWRgvImYeGoGRve4MpjumHDXjpiNn0MU85DDRMTcLYHqI0kReQj05BCj/B/2NjTa6UMWggi0NkMajlCEmq/Ze8q6UjWEsz6hkoCHdfOYR8AnTUHg9QkvHryF1l+CqfawcU6a9j+6h9aYCNQJpnLPKgVEqEOI7qFOR46jNq1DbX5JkyzPV7B2pdL root@kht130
5.将master推送到githud
[root@kht130 kht]# git push -u origin master
Counting objects: 24, done.
Compressing objects: 100% (19/19), done.
Writing objects: 100% (24/24), 1.88 KiB | 0 bytes/s, done.
Total 24 (delta 9), reused 0 (delta 0)
remote: Resolving deltas: 100% (9/9), done.
To github.com:zhkht/test.git
* [new branch] master -> master
Branch master set up to track remote branch master from origin.
6.克隆代码(ssh)
[root@kht130 aa]# git clone git@github.com:zhkht/test.git
在githud使用秘钥