工欲善其事,必先利其器。

在OS X Yosemite 10.10.3安装最新版本号Xcode。在terminal下能够发现git已经被安装。

~ mesut$ git --version
git version 2.3.2 (Apple Git-55)

之前就已经注冊而且使用Github了,只是一直都是在window 系统下远程管理。

如今開始设置Mac管理Github,有一点须要知道的是本地的git仓库和Githubserver之间是通过ssh加密的。

在终端运行

ozil:tmp mesut$ ssh -v
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
usage: ssh [-1246AaCfgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec][-D [bind_address:]port] [-e escape_char] [-F configfile][-I pkcs11] [-i identity_file][-L [bind_address:]port:host:hostport][-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port][-R [bind_address:]port:host:hostport] [-S ctl_path][-W host:port] [-w local_tun[:remote_tun]][user@]hostname [command]

明显Mac已经安装了ssh。

1:创建SSH Key

ozil:tmp mesut$ cd ~
ozil:~ mesut$ pwd
/Users/mesut
ozil:~ mesut$ cd .ssh
-bash: cd: .ssh: No such file or directory
ozil:~ mesut$ 

进入当前的用户文件夹。波浪线表示的是当前文件夹。

推断是否已经安装了.ssh,避免默认安装会覆盖之前安装的。

明显当前文件夹没有该文件

运行创建 ssh key

ssh-keygen -t rsa -C "youremail@example.com"(你的Github登陆名)

接着都是回车,选择默认的文件夹,默认的password就可以

Generating public/private rsa key pair.
Enter file in which to save the key (/Users/mesut/.ssh/id_rsa):
Created directory '/Users/mesut/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/mesut/.ssh/id_rsa.
Your public key has been saved in /Users/mesut/.ssh/id_rsa.pub.

接着能够在用户主文件夹里找到.ssh文件夹,里面有id_rsaid_rsa.pub两个文件,这两个就是SSH Key的秘钥对

ozil:~ mesut$ cd .ssh
ozil:.ssh mesut$ ls
id_rsa      id_rsa.pub

2:在Github设置ssh key

登陆Github, “Settings”->"SSH keys"->"Add SSH key"

title:能够顺便填名字

key:在Key文本框里粘贴id_rsa.pub文件的内容

点击add key 配置完毕

3:測试本地是否和Github连接上

史蒂夫

ozil:.ssh mesut$ ssh -T git@github.com
The authenticity of host 'github.com (xxx)' can't be established.
RSA key fingerprint is xxx.
Are you sure you want to continue connecting (yes/no)? yes

第一次链接Github,会有一个确认。须要你确认GitHub的Key的指纹信息是否真的来自GitHub的server,输入yes回车就可以。

Warning: Permanently added 'github.com,xxx' (RSA) to the list of known hosts.Hi tanchongshi! You've successfully authenticated, but GitHub does not provide shell access.

4:使用git在本地建立的项目更新到Github

ozil:githubspace mesut$ mkdir hellogithub
ozil:githubspace mesut$ cd hellogithub/
ozil:hellogithub mesut$ ls -ah
.   ..
ozil:hellogithub mesut$ git init
Initialized empty Git repository in /Users/mesut/Documents/githubspace/hellogithub/.git/
ozil:hellogithub mesut$ ls -ah
.   ..  .git
ozil:hellogithub mesut$ touch newfile
ozil:hellogithub mesut$ ls
newfile
ozil:hellogithub mesut$ git add newfile
ozil:hellogithub mesut$ git commit -m 'first commit'
[master (root-commit) 2295d3e] first commitCommitter: >v< <mesut@ozil.local>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly. Run the
following command and follow the instructions in your editor to edit
your configuration file:git config --global --editAfter doing this, you may fix the identity used for this commit with:git commit --amend --reset-author1 file changed, 0 insertions(+), 0 deletions(-)create mode 100644 newfile

首先在本地初始化一个git仓库

因为之前没有配置username。所以首次commit会有提示。自己主动建立

设置方式

$ git config --global user.name "Your Name"
$ git config --global user.email "email@example.com"

为了把本地库推到远程server,首先须要在Github上面也建一个项目

在Repository name填上我们的项目名字。description随便填,别的默认。

然后会生成项目

然后把远程项目和本地库关联

ozil:hellogithub mesut$ git remote add origin git@github.com:tanchongshi/hellogithub.git
ozil:hellogithub mesut$ git push -u origin master
Warning: Permanently added the RSA host key for IP address 'XXX' to the list of known hosts.
Counting objects: 3, done.
Writing objects: 100% (3/3), 217 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@github.com:tanchongshi/hellogithub.git* [new branch]      master -> master
Branch master set up to track remote branch master from origin.

https://github.com/tanchongshi/hellogithub

so far so good~

转载于:https://www.cnblogs.com/claireyuancy/p/7252551.html

mac使用git管理Github相关推荐

  1. mac使用git管理Github以及生成 SSH 公钥

    现在开始设置Mac管理Github,有一点需要知道的是本地的git仓库和Github服务器之间是通过ssh加密的. 在终端执行 ? 1 2 3 4 5 6 7 8 9 10 ozil:tmp mesu ...

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

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

  3. Windows 下使用Git管理Github项目

    Git Git是一个开源的分布式版本控制系统,用以有效.高速的处理从很小到非常大的项目版本管理.最初由Linus Torvalds编写,用作Linux内核代码的管理.在推出后,Git在其它项目中也取得 ...

  4. 使用git管理github项目

    http://progit.org/book/zh/ Git是一个分布式的版本控制系统,最初由Linus Torvalds编写,用作Linux内核代码的管理.在推出后,Git在其它项目中也取得了很大成 ...

  5. git管理github仓库详解

    内容精简 初始化 git init 克隆项目到本地 git clone '当前项目的git地址' 如果要输入用户名密码 就输入: 配置用户名邮箱 git config –global user.nam ...

  6. mac下git与github简单使用

    准备工作: 下载安装git客户端 http://code.google.com/p/git-osx-installer/downloads/list?can=3 注册github账号 https:// ...

  7. windows下使用git管理github项目

    1. 下载安装msysgit http://code.google.com/p/msysgit/downloads/list 2. 注册github账号 3. 生成ssh公钥和私钥 ssh-keyge ...

  8. git与github远程连接代码库使用笔记

    一.安装与账号添加 1.git安装 目前windows版本的git有几种实现,但我们选择msysgit发行版,这是目前做得兼容性最好的.下载地址:http://code.google.com/p/ms ...

  9. git与github从入门到精通

    1.了解Git和Github 1.1 什么是Git Git是一个免费.开源的版本控制软件 1.2 什么是版本控制系统 版本控制是一种记录一个或若干个文件内容变化,以便将来查阅特定版本修订情况得系统. ...

最新文章

  1. 外部工具连接SaaS模式云数仓MaxCompute 实战—— 数据库管理工具篇
  2. 函数可重入性及编写规范
  3. windows服务器迁到_Windows Server 2008 R2 DNS 服务器迁移方法
  4. do与mysql数据类型对照_dophon-db: dophon框架的数据库模块,支持mysql,sqlite数据库,带有orm持久化功能与链式操作实例,贴近逻辑习惯,支持mysql多数据源配置...
  5. sdcv: 在Ubuntu中使用命令行查询离线英文词典
  6. 为什么QQ浏览器不是默认浏览器但是在打开网页的时候还是默认启动?
  7. Android WebView使用深入浅出
  8. Redis数据类型之字符串String
  9. tcp压测工具_使用BeetleX的TcpBenchmark工具进行百万设备模拟测试
  10. express中 routes/index.js
  11. css鼠标移上去向上移动,css3鼠标移动图片上移效果
  12. wineskin下plsql解决中文乱码问题
  13. 一款万能企业邮箱,高效且实用,速看!
  14. JavaScript数组反转教程
  15. 珠海横琴凯悦酒店开业
  16. 免费申请Jetbrains的产品
  17. 嵌入式开发要学什么_必备嵌入式学习路线_高手速成方法
  18. Excel根据内容自动调整行高和列宽
  19. 君子生非异也,善假于物也
  20. 那么浙江大学软件工程专业复试考试内容有哪些

热门文章

  1. 创建学生成绩数据库的简单sql语句
  2. 37互娱,2019秋招提前批,Java服务端二面
  3. 浙江省八年级python_今年9月起 浙江八年级新增Python编程课程
  4. 毫米波雷达的系统设计细节(1) - 从雷达方程到雷达威力图
  5. Hyper-V虚拟化
  6. 10个打开了我新世界大门的 WebAPI
  7. uniapp如何引入iconfont图标库
  8. C#字符串转换为ASCII码
  9. 安装yolov5时,遇到的问题
  10. linux系统下html中文乱码