Mac Git配置

在使用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


最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。