mac下git命令自动补全

获取脚本

curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash

在~/.bash_profile中加上

if [ -f ~/.git-completion.bash ]; then
  . ~/.git-completion.bash
fi

添加执行权限

chmod -x ~/.git-completion.bash 

编译文件
source ~/.git-completion.bash

具体如下:

zhaojunyandeMBP:goproject zhaojunyan$ curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 69413  100 69413    0     0  18360      0  0:00:03  0:00:03 --:--:-- 18358
zhaojunyandeMBP:goproject zhaojunyan$ 
zhaojunyandeMBP:goproject zhaojunyan$ vim ~/.bash_profile  
zhaojunyandeMBP:goproject zhaojunyan$ chmod -x ~/.git-completion.bash 
zhaojunyandeMBP:goproject zhaojunyan$ source ~/.git
.git-completion.bash  .gitconfig            
zhaojunyandeMBP:goproject zhaojunyan$ source ~/.git-completion.bash 
zhaojunyandeMBP:goproject zhaojunyan$ git branch 
  develop
  master
* uat
zhaojunyandeMBP:goproject zhaojunyan$ 

猜你喜欢

转载自blog.csdn.net/Nick_666/article/details/80043713
今日推荐