Mac Git配置

2018-09-22  本文已影响0人  可爱的尖椒肉丝

在使用Mac进行编码过程中,为了适应自己的使用习惯,针对Git 进行一些优化配置,主要配置如下:

1. git 自动补全

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

    2)vi ~/.bash_profile

    3)if [ -f ~/.git-completion.bash ]; then. ~/.git-completion.bashfi

    4)source ~/.bash_profile


2. git显示当前分支

    1)vi .bashrc

    2) function git_branch {

      branch="`git branch 2>/dev/null | grep "^\*" | sed -e "s/^\*\ //"`"

      if [ "${branch}" != "" ];then

          if [ "${branch}" = "(no branch)" ];then

              branch="(`git rev-parse --short HEAD`...)"

          fi

          echo " ($branch)"

      fi

    }

    export PS1='\u@\h \[\033[01;36m\]\W\[\033[01;32m\]$(git_branch)\[\033[00m\] \$ '

    3) source ./.bashrc


上一篇 下一篇

猜你喜欢

热点阅读