MAC下Git的安装与命令行设置

一、Mac安装Git
有多种安装方式,安装更新的版本,可以使用二进制安装程序;
官方维护的 OSX Git安装程序可以在Git官方网站下载;
网址为 http://git-scm.com/download/mac;
安装时请仔细阅读安装包中的README.TXT文档。


二、Git中文手册
https://git-scm.com/book/zh/v2


三、Bash中Git自动补全功能与命令提示符配置
3.1.下载git Shell插件,下载链接:
https://github.com/git/git
解压压缩包,进入contrib/completion文件夹,其中
git-completion.bash
git-prompt.sh
两个文件主要是在git 输入命令时可以自动完成及有内容提示,防止输入命令出错

3.2.把上面这两个文件拷贝到当前用户home目录下
cp git-completion.bash ~/.git-completion.bash
cp git-prompt.sh ~/.git-prompt.sh

3.3.修改.bash_profile
vim .bash_profile
输入以下内容
# copy contrib/copmletion/git-completion.bash to your home directory and source it
# Linux users should add the line below to your .bashrc
. ~/git-completion.bash

#copy contrib/completion/git-prompt.sh to your home directory and source it
#Linux users should add the line below to your .bashrc
. ~/git-prompt.sh
export GIT_PS1_SHOWDIRTYSTATE=1
# export PS1='\w$(__git_ps1 " (%s)")\$'
export PS1='\u:\W$(__git_ps1 " (%s)")\$ '

\w 表示打印当前工作目录,\$ 打印 $ 部分的提示符(prompt),__git_ps1 " (%s)" 表示通过格式化参数符(%s)调用`git-prompt.sh`脚本中提供的函数。 因为有了这个自定义提示符,现在你的 Bash 提示符(prompt)在 Git 仓库的任何子目录中都将显示成这样:

保存退出并source 一下.bash_profile

 

四、可视化客户端SourceTree安装

下载链接:https://www.sourcetreeapp.com

默认安装即可。

posted @ 2017-05-10 23:08  ileveli  阅读(7545)  评论(0编辑  收藏  举报