2015-11-04 113 views
2

我有一个与centOS系统的VPS。系统在正常情况下具有较高的负载。键入“cd”命令到linux git目录时发生了什么?

我有一个非常大(近800M)的git目录,当我输入命令cd到目录时,需要花费这么长的shell响应时间。

所以我的问题是,当我向git direcoty输入cd时发生了什么?我能做些什么来优化输入时间?

这里添加我的bash简介:

这是我的.bash_profile:

function parse_git_dirty { 
    [[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*" 
} 

function parse_git_branch { 
    git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/" 
} 
export PS1='\[email protected]\h:\w\[\e[1;36m\]$(parse_git_branch)\[\e[0m\]$ ' 
+0

也许是最好的* *你可以做的事情就是重构你的项目,所以没有单独的目录是800MB!但是,不,我想不出任何“cd”应该是“昂贵”的原因。在“git”和/或shell中。 – paulsm4

+3

简单的'cd'甚至不会查看目录的内容。你必须有一个别名,或一个奇特的提示或做一些额外的工作。 –

回答

4

检查,如果你有这可能会花费太多时间来显示(因为git status in a large repo can be costly

混帐PS1提示

See this gist例如,它帮助禁用提示时,你做一个Ctrl + C

(摘录)

local this_git_status="" 
    if [ -z "${_skip_git_ps1}" ]; then 
     this_git_status=$(__git_ps1 "(%s)") 
     case $? in 
      0) : ;; 
      130) git_ps1_disable;; # If we break that last command because it's too slow, stop trying it 
     esac 
    fi 
    export PS1=": \[email protected]\h \w${this_git_status}; " 
+0

同时检查'$ PROMPT_COMMAND' –

+0

非常感谢。我在我的bash点文件中找到了一个PS1促进器。似乎有一些缓存就像东西,当我再次进入目录时,即使使用原点文件,响应时间也很短。我将删除它并稍后进行测试。 – FisherMartyn

相关问题