GIT与GitHub(Mac版)

本人的在操作系统是Mac,即Mac版本下Git 的使用方法,如下:

1.预备工作:

安装git,首先在官网上下载一个git安装包,安装在本地,一直下一步,填好自己的github帐号和密码。

2.创建ssh:

$ ssh-keygen -t rsa -C  < your email>  (后面的是git上注册的邮件哦)

$ vim id_rsa.pub (用vim命令打开文件可以复制一下啦)

3..登录github设置一下账户里的ssh key:

在登录后直接点击右上方的工具按钮,也就是页面最上方从右边数第二个按钮(Account settings)

进入Account setting之后,页面左侧有一列菜单,里面有一项是 SSH keys,点击后页面右侧会有add SSH keys的选项,点击后就可以把之前vim id_rsa.pub之后的内容粘贴过来啦。

4.测试SSH:
       $ssh git@github.com

5.设置本地git个人信息:
        $git config --global user.name "your real name"
        $git config --global user.email "xxxxx@gmail.com"

在github中创建Repository:
      https://github.com/ --> New Repository 输入Repository信息 projectName
在本地创建代码库:
      创建一个文件夹作为local repository
      $mkdir test
      创建一个文件
       $cd test
       $vi test.txt
       将文件添加至local repository
       $git add test.txt
       初始化local repository
       $git init
       commit文件
       $git commit -a
       定义远程服务器别名
       $git remote add alias git@github.com:xxxxx/projectName.git
       将本地数据push到github上
       $git push alias master
这样就可以将本地的代码push到github的repository中了。

参考文献:http://blog.csdn.net/qjlhlh/article/details/8139787

 

posted @ 2017-09-06 13:49  Among  阅读(368)  评论(0编辑  收藏  举报