Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
键入“时会发生什么?”;cd";命令到LinuxGit目录?_Linux_Git_Shell - Fatal编程技术网

键入“时会发生什么?”;cd";命令到LinuxGit目录?

键入“时会发生什么?”;cd";命令到LinuxGit目录?,linux,git,shell,Linux,Git,Shell,我有一个使用CentOS系统的VPS。系统在正常时间具有高平均负载 我有一个非常大的Git目录(接近800MB)。当我在目录中键入commandcd时,shell需要很长时间才能响应 在Git目录中键入cd时会发生什么?如何优化输入时间 在此处添加我的Bash配置文件: 这是我的.bash\u配置文件文件: function parse_git_dirty { [[ $(git status 2> /dev/null | tail -n1) != "nothing to commi

我有一个使用CentOS系统的VPS。系统在正常时间具有高平均负载

我有一个非常大的Git目录(接近800MB)。当我在目录中键入command
cd
时,shell需要很长时间才能响应

在Git目录中键入
cd
时会发生什么?如何优化输入时间

在此处添加我的Bash配置文件:

这是我的
.bash\u配置文件
文件:

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='\u@\h:\w\[\e[1;36m\]$(parse_git_branch)\[\e[0m\]$ '

检查是否有git PS1提示符,该提示符可能需要太多时间才能显示(因为

例如,这有助于在执行Ctrl+C操作时禁用提示:

(摘录)


也许你能做的最好的事情就是重构你的项目,这样没有一个目录是800MB!但是不,我想不出任何理由一张“cd”应该是“昂贵的”。在“git”和/或shell中。普通的
cd
甚至不会查看目录的内容。你必须有一个别名,或者一个漂亮的提示符或者做额外工作的东西。另外请检查
$prompt\u命令
非常感谢。我确实在我的bash点文件中找到了一个PS1 promot。似乎有一些类似缓存的东西,当我再次进入目录时,即使是原始点文件,响应时间也很短。我将删除它,稍后进行测试。
    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=": \u@\h \w${this_git_status}; "