linux bash平台下查看linux分支

# .bash_profile
# 在.bash_profile加上以下两句
function git-branch-name {
git symbolic-ref --short -q HEAD 2>/dev/null
}
function git-branch-prompt {
local branch=`git-branch-name`
if [ $branch ]; then printf " [%s]" $branch; fi
}
在Linux的Bashshell中,可以通过创建两个函数`git-branch-name`和`git-branch-prompt`来方便地查看当前Git分支。`git-branch-name`函数使用`gitsymbolic-ref--short-qHEAD`命令获取分支名,而`git-branch-prompt`函数会在命令行提示符中显示分支信息,如果在某个Git工作目录下,它会显示[branch_name]。
541

被折叠的 条评论
为什么被折叠?



