Git 备忘

来源:互联网 发布:php date日期格式化 编辑:程序博客网 时间:2024/04/26 14:00

1. Config

$ git config --global user.name "John Doe"

$ git config --global user.email johndoe@example.com

2. 显示分支的名字

http://blog.163.com/my_ywj/blog/static/181203559201222933040599/

find_git_branch () {    local dir=. head    until [ "$dir" -ef / ]; do        if [ -f "$dir/.git/HEAD" ]; then            head=$(< "$dir/.git/HEAD")            if [[ $head = ref:\ refs/heads/* ]]; then                git_branch=" | ${head#*/*/}"            elif [[ $head != '' ]]; then                git_branch=" | (detached)"            else                git_branch=" | (unknow)"            fi              return        fi          dir="../$dir"    done    git_branch=''}PROMPT_COMMAND="find_git_branch; $PROMPT_COMMAND"PS1="\u@\h:\w\$git_branch\$ "

把上面的代码加入到 .bashrc下,以后进入终端cd到有git仓库的地方就会显示当前分支名(我的为a2),否则显示detached


3. http://www.01happy.com/centos-git-autocomplete-command/ git 自动补全

原创粉丝点击