现在的位置: 首页Mac教程 > 正文
在Mac OS X下安装Git
关键词:Mac OS X Git ┊ 来源: 原创收藏

一、安装Git

方法一:dmg安装包在http://code.google.com/p/git-osx-installer/下载,十分简单就不重复了

方法二:通过类似于 Homebrew 或者 MacPorts 的包管理来安装

Homebrew

$ sudo brew install git

MacPorts

$ sudo port selfupdate
$ sudo port install git-core

二、设置SSH

github使用SSH链接,需要设置SSH

1.检查SSH key

     cd ~/.ssh

2.备份已有的key,(如果有的话)

     mkdir key_backup

     mv id_rsa* key_backup

3.生成SSH key

$ ssh-keygen -t rsa -C jiang.bo.hit@gmail.com

Generating public/private rsa key pair.

Enter file in which to save the key (/Users/jiangbo/.ssh/id_rsa):

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in yes.

Your public key has been saved in id_rsa.pub.

The key fingerprint is:

fb:c4:b0:e0:47:fd:be:e0:fb:ea:73:ef:a8:29:d5:22 jiang.bo.hit@gmail.com

The key's randomart image is:

+--[ RSA 2048]----+

|                 |

|                 |

|                 |

|         .       |

|      . S ..     |

|     . oE=o..    |

|      . +o+..    |

|       ..+.+..   |

|         oOB=+o  |

+-----------------+

4.将SSH key添加到GitHub

登录到GitHub页面,Account Settings->SSH Public Keys->Add another key

将生成的key(id_rsa.pub文件)内容copy到输入框中,save。

Mac OS X安装Git

5.测试链接

$ 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

PTY allocation request failed on channel 0

Hi jiang-bo! You've successfully authenticated, but GitHub does not provide shell access.

         Connection to github.com closed.

别担心,这是正常情况。

三、设置个人信息

$ git config --global user.name "Bo Jiang"

$ git config --global user.email "jiang.bo.hit@gmail.com"

本文由 jack 发布于 2319天 5小时 17分钟前,目前已有 6606 人浏览
欢迎大家转载分享,请注明来源及链接;商业媒体转载请获得授权,谢谢合作!
 

添加评论