MAC 上安装Git主要有两种方式:
1. 通过 Homebrew 安装Git
- 1、安装 Homebrew 见 3 Homebrew。
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
- 2、安装Git
brew install git
2. 通过Xcode安装
直接从AppStore安装Xcode,Xcode集成了Git,不过默认没有安装,你需要运行Xcode,选择菜单“Xcode”->“Preferences”,在弹出窗口中找到“Downloads”,选择“Command Line Tools”,点“Install”就可以完成安装了。
来测试一下 git
是否安装完好:
$ git --version
运行 $ which git
将会输出 /usr/local/bin/git
.
接着,我们将定义你的 Git 帐号(与你在 GitHub 使用的用户名和邮箱一致)
$ git config --global user.name "Your Name Here"
$ git config --global user.email "[email protected]"
这些配置信息将会添加进 ~/.gitconfig
文件中.