bash-git-prompt
bash-git-prompt copied to clipboard
my prompt is slow with bash-git-prompt
I am using bash-git-prompt: stable 2.7.1 and it is slow, but only when i open directory with git repository in it. The lag is around 2 seconds after any command, for example 'ls'. How to debug what causes this lag? Not every repository affected, but some does.
I'm seeing this behavior too. I've got GIT_PROMPT_ONLY_IN_REPO=1 and the terminal is still slow in all directories.
This is an intermittent problem and restarting my computer (not just restarting terminal) resolves it.
Seems like it becomes slower if there is a lot of files in the git folder, or if the .git metadata is big. I'm running this in WSL2, and on a windows drive (that is mapped into the Linux VM) it can take 5-10 seconds to return to the prompt after the file listing. Doing the same with an identical copy of the git folder in the Linux filesystem takes 1-2 seconds, still slow.
Makes me think that every time the prompt renders, it must use massive disk IO. Not sure if that could be improved, but feels like it should be improvable, at least with some caching.
I have this issue as well. In particular on a repo with a large amount of files (~80K) over nfs, it can take more than 90 seconds just to return to the prompt after any command.
I've tried setting various options to ignore untracked files and using update-index but I don't really see any improvement.
Have you tried these suggestions in the README
"If you have a repository with many untracked files, the git prompt can become very slow. You can disable the display of untracked files on a per repository basis by setting GIT_PROMPT_SHOW_UNTRACKED_FILES=no in your .bash-git-rc in the repository or by disabling it globally in your .bashrc
If you have a repository with a deep submodule hierarchy, this can also affect performance. You can disable searching for changes in submodules on a per repository basis by setting GIT_PROMPT_IGNORE_SUBMODULES=1 in your .bash-git-rc"
Regards ian
I'm seeing this behavior too.
Same problem here under WSL2
Same under Fedora.
When this happens in WSL2, the most likely cause seems to be the filesystem performance in mounted directories. In /mnt, the Windows filesystem is accessed from within a Linux VM, and the process is dead slow, as explained here. Even git status takes forever in some repos. And if git status is slow, bash-git-prompt will be, too.
I was having a similar issue with a git-lfs repo with only a few hundred files, albeit large ones. Manually running git status solved the problem (not sure how often that needs to be done).
https://github.com/magicmonty/bash-git-prompt/pull/491 is merged now. @retif Could you confirm that this solves your issue?