Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git status command is very slow

Tags:

git

My git status command is getting slow recently.

I tried to trace the execution:

GIT_TRACE=1 GIT_CURL_VERBOSE=2 git status

Output:

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 --

And I found in the two steps it take 10 seconds:

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'

My git environment:

  • macOS 10.13.4 (17E199)
  • git version 2.17.0

Is there anyone coming into the same issue? I'm not familiar with the details with Git.

like image 888
Evans Y. Avatar asked Dec 14 '22 17:12

Evans Y.


1 Answers

Try first to check if the presence of submodules migh influence the git status performance, using the --ignore-submodules[=<when>] option:

git status --ignore-submodules=all

Also, make sure your repo is clone locally, not on a remote drive, which would add latency to any Git operation.

like image 164
VonC Avatar answered Dec 17 '22 23:12

VonC