03月01, 2018

git整理

git config

git config --global alias.b branch
git config --global alias.s status

git命令自动补全

  1. 安装 git completion brew install git-completion
  2. 下载git源码,找到git-completion.sh((contrib/completion)并复制。
    git clone https://github.com/git/git.git
    

    git显示分支

    在.bash_rc增加
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\] \$ '

Refs:

  1. https://git-scm.com/book/zh/v1/Git-%E5%9F%BA%E7%A1%80-%E6%8A%80%E5%B7%A7%E5%92%8C%E7%AA%8D%E9%97%A8
  2. https://www.jianshu.com/p/40e25d964d2f
  3. https://gist.github.com/yisibl/8281454

本文链接:http://fengbaiyang.cn/post/git-config.html

-- EOF --

Comments

暂不支持评论,如有问题,请发邮件至baiyang.feng@outlook.com。 望不吝赐教~