mac上的命令很好用,但是在配合 git 的時候 tab 不能進行自動補全,這個比較坑,作爲一個開發來講這個不能容忍的,結下來我們來介紹一下mac下如何讓git可以自動補全。
-
安裝git
// 查看 brew 安裝文件列表是否有git brew list // 直接檢查git是否安裝 git --version 產看版本 git --version // 通過brew進行安裝 brew install git
-
安裝bash-completion
// 這個過程可能回比較慢,耐心等待 brew bash-completion
-
下載git-completion.bash文件
// 將源碼下載到本地 git clone https://github.com/git/git.git // 找到 git/contrib/completion/git-completion.bash 文件並將 git-completion.bash 複製到 ~/ 並重命名爲 .git-completion.bash cp git-completion.bash ~/.git-completion.bash
-
配置git-completion.bash
// 打開 ~/.bash_profile 文件 如果沒有通過 touch ~/.bash_profile 新建 open ~/.bash_profile // 把 以下代碼 copy 到 bahs_profile中 if [ -f ~/.git-completion.bash ]; then . ~/.git-completion.bash fi source ~/.git-completion.bash
-
關閉終端並重啓
參考文檔:
git自動補全一
git自動補全二
git自動補全三
以上就是關於mac下git 補全的配置方法,希望對大家有所幫助親測有效