使用GITHUB笔记
假设大家都已经可以使用GIT,知道一些GIT命令。
1.注册账户以及创建仓库
要想使用github第一步当然是注册github账号了。链接地址:github.com
2.安装客户端git
这个就不罗嗦啦,去网络上搜索下载并安装吧
3.配置Git
首先在本地创建ssh key
$ ssh-keygen -t rsa -C "your_email@youremail.com"
后面的your_email@youremail.com改为你的邮箱,之后会要求确认路径和输入密码,我们这使用默认的一路回车就行。成功的话会在~/下生成.ssh文件夹,进去,打开id_rsa.pub,复制里面的key。例如:
[root@mail git]# ssh-keygen -t rsa -C "yourname@163.com" Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is: d7:21:20:c1:d0:62:3e:16:56:b3:4f:aa:7b:0e:5f:0f youremail@163.com
回到github,进入Account Settings-->SSH KEYS-->add ssh key(左边选择SSH Keys,右边选择Add SSH Key);title随便填,粘贴key。
注意的是,你的key是~/.ssh/id_rsa.pub。例如:
ssh-rsa AAbbB3NzaC1yc2EAAAABIwAAAQEAr3rZITHygnkDiKt9a/E4gzKxMEtGoXSfbriqPMOFtiK3G8F868GZ5WWkX7oMExAe4T2gliWBlcwvJh+wrBG4Xes4/hJl3j6MeNsEa+fxVZT1cl7tv0ELRXiZBxB1mrYQZzzjHhy/EGzZIqgnmvewLjqNh/z0pQLHtnHRHioS2hE3XIE8ijao2Zsx5hT4xeqeGl5E88S8gbG8nzooN3i9HzcbBr7Flo8YN+FPOcPxLx1h4DFEj9QTMn9LKmCTd+7ktQyp6XT4GNc8at6XxHU+jEpAw60Kg40j0GZJIlXqQTSu3huC+rKpyrcKe3dtn9wbNEPi8oODP4N93Jl0sNVaLw== youremail@163.com
那么在github.com需要输入的内容是:
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAr3rZITHygnkDiKt9a/E4gzKxMEtGoXSfbriqPMOFtiK3G8F868GZ5WWkX7oMExAe4T2gliWBlcwvJh+wrBG4Xes4/hJl3j6MeNsEa+fxVZT1cl7tv0ELRXiZBxB1mrYQZzzjHhy/EGzZIqgnmvewLjqNh/z0pQLHtnHRHioS2hE3XIE8ijao2Zsx5hT4xeqeGl5E88S8gbG8nzooN3i9HzcbBr7Flo8YN+FPOcPxLx1h4DFEj9QTMn9LKmCTd+7ktQyp6XT4GNc8at6XxHU+jEpAw60Kg40j0GZJIlXqQTSu3huC+rKpyrcKe3dtn9wbNEPi8oODP4N93Jl0sNVaLw==
为了验证是否成功,在git bash下输入:
ssh -T git@github.com
如果是第一次的会提示是否continue,输入yes就会看到:You’ve successfully authenticated, but GitHub does not provide shell access 。这就表示已成功连上github。
接下来我们要做的就是把本地仓库传到github上去,在此之前还需要设置username和email,因为github每次commit都会记录他们。
$ git config --global user.name "your name" $ git config --global user.email "your_email@youremail.com"
4.github创建自己的仓库
github.com网站的右上角有个图标,点击“create a new repo”
5.下载刚刚已经创建的GIT仓库
$ git clone git@github.com:yourname/projectname.git
成功!!!
顺便宣传一下我刚刚建立的GITHUB地址:https://github.com/lihehuo