Git Status Takes a Long Time to Complete

WindowsGit

Windows Problem Overview


I'm using git to manage files in a local directory on a Windows machine - no network is involved here, I'm not pushing or pulling to/from another machine. My directory has maybe 100 files in it, all test files, pretty small. When I run git status, it regularly takes 20-30 seconds to complete. Is this normal? Is there anything I can do to speed it up, or a better way to see what the state of my repository is (changed files, untracked files, etc)? Other git commands seem to complete much faster.

Windows Solutions


Solution 1 - Windows

Have you tried git gc? This cleans cruft out of the git repo.

Solution 2 - Windows

Running git fsck has resolved this issue for me in the past.

Solution 3 - Windows

Have you tried repacking? git-repack.

Otherwise, try duplicating the directory, and deleting the .git folder in the duplicated directory. Then create a new git directory and see if it's still slow.

If it's still slow, then it sounds like a system or hardware issue. Git finishes status on hundreds of files for me in less than 5 seconds.

Solution 4 - Windows

Are you using some kind of virus protection software? Maybe that is interfering with things. git is very fast for me on windows with repositories of 1000's of files.

Solution 5 - Windows

On a similar issue I found that having a git repo in a directory below my existing git repo caused a massive slow down.

I moved the secondary git repo somewhere else and now the speed is fast!

Solution 6 - Windows

For some reason git status is particularly slow after moving or copying the repository folder to a new location.

Subsequent runs are usually quicker in this case.

Solution 7 - Windows

My git status was very slow (up to one minute), because the global .gitignore file was located in my windows userprofile, which was stored on an inaccessible network share.

git config --global core.excludesfile
showed something like \\Nxxxx0\User\Username\Eigene Dateien\gitignore_global.txt

For some reason \\Nxxxx0 was inaccessible and my userprofile was loaded from a backup system \\Nxxxxx1. It took some time to figure that out, because usually my userprofile is bound to a drive letter by an enterprise startup script and accessing that drive letter was working as usual. I'm not sure why the git-config used the network share and not the drive letter (probably a younger me is to blame)

After setting
git config --global core.excludesfile $HOME/Eigene\ Dateien/gitignore_global.txt
git status was back to normal speed.

Solution 8 - Windows

For me, the slowness was due to having a lot of untracked files (temporary and output files from scripts.) Running git status -uno, which excludes the untracked files, ran much faster, and meets my requirements

Solution 9 - Windows

Older versions of git have a performance issue with git status - see https://stackoverflow.com/questions/4994772/ways-to-improve-git-status-performance/43644347#43644347 for more info.

git 2.13 has 1 fix, and 2.17 more. i moved from 2.7 to 2.23 and it resolved slow status. There is another improvement planned for 2.24 soon.

Solution 10 - Windows

Another aspect of git status which will be improved (in Git 2.14.x/2.15, Q4 2017) is when it shows ignored files as well (git status --ignored)

> "git status --ignored", when noticing that a directory without any tracked path is ignored, still enumerated all the ignored paths in the directory, which is unnecessary.
The codepath has been optimized to avoid this overhead.

See commit 5aaa7fd (18 Sep 2017) by Jameson Miller (jamill).
(Merged by Junio C Hamano -- gitster -- in commit 075bc9c, 29 Sep 2017)

> ## Improve performance of git status --ignored

> Improve the performance of the directory listing logic when it wants to list non-empty ignored directories. In order to show non-empty ignored directories, the existing logic will recursively iterate through all contents of an ignored directory.
This change introduces the optimization to stop iterating through the contents once it finds the first file. This can have a significant improvement in 'git status --ignored' performance in repositories with a large number of files in ignored directories.

> For an example of the performance difference on an example repository with 196,000 files in 400 ignored directories:

| Command                    |  Time (s) |
| -------------------------- | --------- |
| git status                 |   1.2     |
| git status --ignored (old) |   3.9     |
| git status --ignored (new) |   1.4     |

For more improvment (set in Git 2.17, Q2 2018), see this answer.

Solution 11 - Windows

In my case there was a huge ZIP file within this git directory. Also *.zip is a line in the .gitignore file:

CMakeCache.txt
CMakeFiles
Makefile
cmake_install.cmake
[...]
*.csv
*.zip
[...]

I have moved this zip file (~915 MB) to some other folder, and this solved the issue.

Solution 12 - Windows

In my case, slowness was caused by running git status as a different user from the owner of the files in the project.

While not applicable in all instance, a simple chown to your current user may do the trick.

Solution 13 - Windows

The issue for me was that I had a lot of different repositories cloned onto my local hard drive, the more repos you have the longer it will take to run commands like git status.

I simply deleted a lot of the repos which I no longer needed locally, and my git status went from 1minute~ to 5 seconds.

I can't see any answers similar to this here.

Solution 14 - Windows

Try starting with a fresh clone of your checkout.

git clone myrepo mynewrepo

and then do git status in mynewrepo.

Alternatively, and if you are braver, clean out the rubbish from your existing checkout.

git clean -dfx

This avoids git having to scan some (possibly large) set of ignored or not checked-in files.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMatt McMinnView Question on Stackoverflow
Solution 1 - WindowsScottView Answer on Stackoverflow
Solution 2 - WindowsBillView Answer on Stackoverflow
Solution 3 - WindowsthedzView Answer on Stackoverflow
Solution 4 - Windows1800 INFORMATIONView Answer on Stackoverflow
Solution 5 - WindowsSargeView Answer on Stackoverflow
Solution 6 - WindowsLexBaileyView Answer on Stackoverflow
Solution 7 - WindowsArigionView Answer on Stackoverflow
Solution 8 - WindowsM. K. HunterView Answer on Stackoverflow
Solution 9 - WindowsBrettView Answer on Stackoverflow
Solution 10 - WindowsVonCView Answer on Stackoverflow
Solution 11 - WindowsAlfred MeierView Answer on Stackoverflow
Solution 12 - WindowsCzar PinoView Answer on Stackoverflow
Solution 13 - WindowsJack PerryView Answer on Stackoverflow
Solution 14 - WindowsAlex BrownView Answer on Stackoverflow