工欲善其事,必先利其器。
在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仓库和Github服务器之间是通过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登陆名)
接着都是回车,选择默认的目录,默认的密码即可
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_rsa