1

I have a considerably large Git repository. As such, I try very hard to avoid running any Git operations which are slow.

For example, my status command is always something like git status -uno -- <dir> which completes nicely within a second (versus git status -u from the root directory which can take up to a minute).

Unfortunately, I have found using git add -i falls into the bucket of "way too slow to be useful". I can trace the command execution, and it seems most of the time is spent in the update-index operation. And no matter what pathspec I provide on the command line, the operation is always performed on the entire workspace.

I would love to use interactive mode while adding files to the index. Is there any way to avoid the full update-index operation or otherwise speed this up?

$ cd cm/
$ GIT_TRACE=1 git add -u -p -- my_file
trace: built-in: git 'add' '-u' '-p' '--' 'my_file'
trace: run_command: 'add--interactive' '--patch' '--' 'cm/my_file'
trace: exec: 'git' 'add--interactive' '--patch' '--' 'cm/my_file'
trace: exec: 'git-add--interactive' '--patch' '--' 'cm/my_file'
trace: run_command: 'git-add--interactive' '--patch' '--' 'cm/my_file'
trace: built-in: git 'rev-parse' '--show-prefix'
trace: built-in: git 'config' '--get-colorbool' 'color.interactive' 'true'
trace: built-in: git 'config' '--get-color' 'color.interactive.prompt' 'bold blue'
trace: built-in: git 'config' '--get-color' 'color.interactive.header' 'bold'
trace: built-in: git 'config' '--get-color' 'color.interactive.help' 'red bold'
trace: built-in: git 'config' '--get' 'color.interactive.help'
trace: built-in: git 'config' '--get-color' 'color.interactive.error' 'red bold'
trace: built-in: git 'config' '--get-colorbool' 'color.diff' 'true'
trace: built-in: git 'config' '--get-color' 'color.diff.frag' 'cyan'
trace: built-in: git 'config' '--get-color' 'color.diff.plain' ''
trace: built-in: git 'config' '--get-color' 'color.diff.old' 'red'
trace: built-in: git 'config' '--get-color' 'color.diff.new' 'green'
trace: built-in: git 'config' '--get-color' '' 'reset'
trace: built-in: git 'config' '--bool' '--get' 'interactive.singlekey'
trace: built-in: git 'rev-parse' '--git-dir'
trace: built-in: git 'update-index' '--refresh'
^C
Alexander
  • 415
  • 3
  • 10
  • Maybe create script, even in sh, that executes those operations that you traced? I suppose you're looking for out-of-the-box solution, so I won't answer, this is just an idea. – Filip Malczak Aug 25 '15 at 19:07
  • Can you change a bit your structure ? If you can, take a look in http://jasonkarns.com/blog/subdirectory-checkouts-with-git-sparse-checkout/. – Cristiano Araujo Aug 25 '15 at 19:09
  • I am looking for an out-of-the-box solution. And yes, reducing the size of the workspace would improve speed. Unfortunately, this is not a viable option for me. – Alexander Aug 25 '15 at 19:19

0 Answers0