准备工作:

下载安装git客户端 http://code.google.com/p/git-osx-installer/downloads/list?can=3
注册github账号 https://github.com/ -->Pricing and Signup -->Create a free account
创建ssh:
在local打开terminal:
$cd ~/.ssh  检查是否已经存在ssh
如果存在,先将已有的ssh备份,或者将新建的ssh生成到另外的目录下
如果不存在,通过默认的参数直接生成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      |
|           .     |
|                 |
|                 |
|                 |
+-----------------+
如果要修改ssh生成目录,在蓝色位置处输入要生成的路径,选择默认的话,会生成在 ~/.ssh下
在github中添加ssh:
登陆github,选择Account Settings-->SSH Public Keys 添加ssh
Title:xxxxx@gmail.com
Key:打开你生成的id_rsa.pub文件,将其中内容拷贝至此
测试SSH:
$ssh git@github.com
The authenticity of host 'github.com (207.97.227.239)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,207.97.227.239' (RSA) to the list of known hosts.
PTY allocation request failed on channel 0
Hi xianfuying! You've successfully authenticated, but GitHub does not provide shell access.
Connection to github.com closed.
在蓝色位置处输入 yes
设置本地git个人信息:
$git config --global user.name "your real name"
$git config --global user.email "xxxxx@gmail.com"
至此,git和github的设置就完成了,下面就是如何将本地代码push到github上,以及如何从github上pull代码了:
在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中了
从github中pull代码:
在github中搜到你想要pull的代码,如https://github.com/edgecase/ruby_koans
选择fork,将此repository fock到你的repository下
在本地创建local repository并初始化
使用命令:
$git pull git@github.com:xxxxx/ruby_koans.git
将github上的代码pull到local repository中
参考:
http://apps.hi.baidu.com/share/detail/16068052
http://blog.csdn.net/banxi1988/article/details/6555293
http://apps.hi.baidu.com/share/detail/31697631

转载于:https://www.cnblogs.com/greywolf/archive/2013/01/28/2879479.html

mac下git与github简单使用相关推荐

  1. Mac下Git与Github的简单使用

    Git是一个分布式的版本控制系统,本文介绍在Mac下如何使用Git管理Github软件项目. 1. 注册Github账号 2. 注册进入主页后,选择页面右上角+:New repository 3. 填 ...

  2. Git和Github简单教程

    网络上关于Git和GitHub的教程不少,但是这些教程有的命令太少不够用,有的命令太多,使得初期学习的时候需要额外花不少时间在一些当前用不到的命令上. 这篇文章主要的目标是用较少的时间学习Git和Gi ...

  3. windows下Git与GitHub的安装及建仓基本操作

    目录 1 安装Git(Git for Windows) 1.1 准备安装文件 1.2 安装 1.3 查看安装结果 1.4 配置Git 2 Git的简单使用 2.1 建仓 2.2 Git指令 2.3 版 ...

  4. Git和Github简单教程【转】

    转自:https://www.cnblogs.com/schaepher/p/5561193.html#clone 原文链接:Git和Github简单教程 网络上关于Git和GitHub的教程不少,但 ...

  5. Linux下Git和GitHub使用方法总结(Ubuntu16.04)

    1 Linux下Git和GitHub环境的搭建 第一步: 安装Git,使用命令 "sudo apt-get install git" 第二步: 创建GitHub帐号 第三步: 生成 ...

  6. linux下git和github搭建使用教程

    一:linux下git和github搭建 1.注册gihub账号: github官网:https://github.com/自行创建即可. 登录,create repository新建仓库一个测试库t ...

  7. Mac下Git安装及配置

    Mac下: 1.下载git版本并安装 运行终端 查看git版本: bogon:~ yan$ git --version git version 2.16.3 配置gitconfig文件 vim ~/. ...

  8. MacOS下Git与GitHub

    还是不知道写啥,本文是有关Mac OS上Git与GitHub相关配置的介绍说明 安装git 该命令也可以升级最新的git brew install git 查看git指向和版本信息 which git ...

  9. Mac下Git项目使用的.gitignore文件

    https://www.gitignore.io/ 这个网站可以搜索特定项目.系统所需要的.gitignore 我现在主要是在Mac上用Visual Studio Code进行开发,所以直接搜索Mac ...

最新文章

  1. 从入门到放弃心得 | 我为什么弃用GAN?
  2. Oracle11g数据库在win7系统上的安装教程
  3. Alibaba微服务事务Seata源码深度剖析 - 笔记
  4. python绝技 — 使用PyGeoIP关联IP地址和物理位置
  5. 力争营收渠道多样化,Line 向自拍应用 Snow 投资 4500 万美元
  6. 给apache安装mod_rewrite模块
  7. TortoiseSVN客户端重新设置用户名和密码[转]
  8. pta通讯录排序用python实现,python实现将android手机通讯录vcf文件转化为csv
  9. 最快学习之Vue Route
  10. 优先级(HTML、CSS)
  11. 禁用行、列、单元格单元格编辑
  12. Dll中的方法向外返回dynamic类型可能会失败
  13. 超详细大学生申请软件著作权登记模板及教程
  14. php文件上传实验总结,php文件上传总结 - osc_jjc36t9p的个人空间 - OSCHINA - 中文开源技术交流社区...
  15. 狗屎一样的React(前言)
  16. Windows 10 21H1开启关闭卓越模式
  17. matlab显示大图像
  18. 二、设计模式-必要的基础知识—旅行前的准备 #和设计模式一起旅行#
  19. SPSS数据文件读取
  20. java鼠标各按键单击和左键击双击

热门文章

  1. java我的世界1.7.2怎么下载模组_我的世界1.7.2
  2. springcloud全局过滤_微服务技术SpringCloud 互联网网站架构演变过程
  3. python多列填充缺点_在Python中比较多列中的值并在另一列中添加新值
  4. java判断星期天_java实现一个月的最后一个星期天
  5. Linux上的gitlab日常操作
  6. matlab scatter cdata,matlab cdatamapping
  7. java加载c库阻塞_【死磕Java並發】-----J.U.C之阻塞隊列:DelayQueue
  8. Win10安装玩Ubuntu19.04后,bios和grub页面都没有Windows启动项,无法进入Windows
  9. python if __name__ == '__main__'
  10. JAVA-初步认识-第十一章-异常-概述