git学习笔记(二) git的一些设置和辅助功能
? ?git config --global user.email "username@email.com" #设置邮件
# 2.颜色设置
? ?git config --global color.diff auto ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?# git diff的时候要显示颜色
? ?git config --global color.status auto ? ? ? ? ? ? ? ? ? ? ? ? ? ? # git status的时候要显示颜色
? ?git config --global color.branch auto ? ? ? ? ? ? ? ? ? ? ? ? ? # git branch的时候要显示颜色
#3.命令别名设置
? ?git config --system alias.st status? ? ? ??# git status命令别名为git st
? ?git config --system alias.ci commit? ? ? # git commit命令别名为git ci
? ?git config --system alias.co checkout??# git checkout命令别名为git co
? ?git config --system alias.br branch? ? ?# git branch命令别名为git br
#4.git 乱码解决
? ?git config --global core.quotepath false? ? ? ? ? ? ? ? ??#文件名不乱码,比如文件名是中文
? ?git config --global gui.encoding utf-8? ? ? ? ? ? ? ? ? ? ? ??#设置git gui的界面编码为UTF-8
? ?git config --global i18n.commitencoding utf-8? ?#设置 git commit -m时commit log 提交时使用 utf-8 编码
? ?git config --global i18n.logoutputencoding gbk??#设置git log输出日志时的编码是GBK
#5.显示分支
? ?修改后可以直关的看到你当前所处在哪个分支,无需通过git branch察看.需要在你的环境变量中如~/.bashrc文件中加入如下内容:
parse_git_branch() { git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(git::\1)/'}export PS1="${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]: \w \[\033[31m\]\$(parse_git_branch)\[\033[00m\]$\[\033[00m\] "? ? 之后再source ~/.bashrc之后,你再进入到一个git目录就能看到所在分支了,类似如下:
? ??/tmp/demo (git::master)$
? ?