一、注册github账号并登录
二、新建repository
根据提示一步步配置即可;
三、安装GIt
Git客户端,点击下载并安装
四、在本机创建ssh
$ssh-keygen -t rsa -C xxxxx@gmail.com(注册github时的email)
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/twer/.ssh/id_rsa):
Created directory '/Users/twer/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/twer/.ssh/id_rsa.
Your public key has been saved in /Users/twer/.ssh/id_rsa.pub.
The key fingerprint is:
18:16:11:c9:01:6c:48:09:7f:27:c6:43:0d:7f:3f:84 xxxxx@gmail.com
The key's randomart image is:
+--[ RSA 2048]----+
|.o.++=== |
|.ooo.+. . |
| ..* = E . |
| o = + o |
| . S o |
| . |
| |
| |
| |
+-----------------+
五、在github中添加SSH keys
在当前账户下:Setting --> SSH keys
点击“New SSH key”,根据提示输入Tille和Key,其中Title为登录github的邮箱,key为本机生生成的id_rsa.pub文件中的内容(打开Finder,使用command+shift+G,输入/Users/本机用户名/.ssh/id_rsa),如下图:
六、上传本地代码到github
1、使用cd,切换到代码目录
2、git init
3、git add . (添加所有文件)
4、git commit -m "comment"
5、git remote add orgin https://github.com/********/Test.git
6、git push -u orgin master
到此,本地代码已更新到github上了,如果git命令不知道的,可以使用“git -- help”查看
参考:
http://www.cnblogs.com/heyonggang/p/3462191.html