我的git status
命令最近变慢了。
我试图跟踪执行情况:
GIT_TRACE=1 GIT_CURL_VERBOSE=2 git status
输出:
10:24:26.589696 run-command.c:640 trace: run_command: GIT_INDEX_FILE=.git/index git submodule summary --cached --for-status --summary-limit 1 HEAD
10:24:26.611043 git.c:576 trace: exec: git-submodule summary --cached --for-status --summary-limit 1 HEAD
10:24:26.611744 run-command.c:640 trace: run_command: git-submodule summary --cached --for-status --summary-limit 1 HEAD
10:24:26.688245 git.c:576 trace: exec: git-sh-i18n--envsubst --variables 'usage: $dashless $USAGE'
10:24:26.688921 run-command.c:640 trace: run_command: git-sh-i18n--envsubst --variables 'usage: $dashless $USAGE'
10:24:26.712823 git.c:576 trace: exec: git-sh-i18n--envsubst 'usage: $dashless $USAGE'
10:24:26.713851 run-command.c:640 trace: run_command: git-sh-i18n--envsubst 'usage: $dashless $USAGE'
10:24:26.754163 git.c:344 trace: built-in: git rev-parse --git-dir
10:24:26.773008 git.c:344 trace: built-in: git rev-parse --git-path objects
10:24:26.788905 git.c:344 trace: built-in: git rev-parse -q --git-dir
10:24:26.832189 git.c:344 trace: built-in: git rev-parse --show-prefix
10:24:26.847857 git.c:344 trace: built-in: git rev-parse --show-toplevel
10:24:26.865076 git.c:344 trace: built-in: git rev-parse -q --verify --default HEAD HEAD
10:24:26.887339 git.c:344 trace: built-in: git rev-parse --show-toplevel
10:24:26.901182 git.c:344 trace: built-in: git rev-parse --sq --prefix --
10:24:26.927138 git.c:344 trace: built-in: git diff-index --cached --ignore-submodules=dirty --raw d6f45eab9517deee0ad8c898ec74b6ce876ba9eb --
10:24:26.941160 run-command.c:640 trace: run_command: GIT_INDEX_FILE=.git/index git submodule summary --files --for-status --summary-limit 1
10:24:26.962172 git.c:576 trace: exec: git-submodule summary --files --for-status --summary-limit 1
10:24:26.962895 run-command.c:640 trace: run_command: git-submodule summary --files --for-status --summary-limit 1
10:24:37.013868 git.c:576 trace: exec: git-sh-i18n--envsubst --variables 'usage: $dashless $USAGE'
10:24:37.014548 run-command.c:640 trace: run_command: git-sh-i18n--envsubst --variables 'usage: $dashless $USAGE'
10:24:37.035160 git.c:576 trace: exec: git-sh-i18n--envsubst 'usage: $dashless $USAGE'
10:24:37.035863 run-command.c:640 trace: run_command: git-sh-i18n--envsubst 'usage: $dashless $USAGE'
10:24:37.064778 git.c:344 trace: built-in: git rev-parse --git-dir
10:24:37.088144 git.c:344 trace: built-in: git rev-parse --git-path objects
10:24:37.106468 git.c:344 trace: built-in: git rev-parse -q --git-dir
10:24:37.144214 git.c:344 trace: built-in: git rev-parse --show-prefix
10:24:37.163255 git.c:344 trace: built-in: git rev-parse --show-toplevel
10:24:37.184273 git.c:344 trace: built-in: git rev-parse -q --verify --default HEAD
10:24:37.201302 git.c:344 trace: built-in: git rev-parse --show-toplevel
10:24:37.220281 git.c:344 trace: built-in: git rev-parse --sq --prefix --
10:24:37.249722 git.c:344 trace: built-in: git diff-files --ignore-submodules=dirty --raw --
我发现这两步需要10秒钟:
10:24:26.962895 run-command.c:640 trace: run_command: git-submodule summary --files --for-status --summary-limit 1
10:24:37.013868 git.c:576 trace: exec: git-sh-i18n--envsubst --variables 'usage: $dashless $USAGE'
我的git环境:
有没有人遇到同样的问题?我不熟悉Git的细节。
答案 0 :(得分:5)
首先尝试使用--ignore-submodules[=<when>]
option检查子模块是否存在影响git状态的效果:
git status --ignore-submodules=all
另外,请确保您的repo是本地克隆,而不是远程驱动器,这会增加任何Git操作的延迟。
答案 1 :(得分:5)
我担心这不仅仅是git状态,也许整个git环境都是滞后的。 请查看此https://github.com/msysgit/msysgit/wiki/Diagnosing-why-Git-is-so-slow。