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

默認安裝即可。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM