Git Status Takes a Long Time to Complete

后端 未结 13 600
一整个雨季
一整个雨季 2020-12-12 20:32

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

相关标签:
13条回答
  • 2020-12-12 20:48

    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.

    0 讨论(0)
  • 2020-12-12 20:48

    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.

    0 讨论(0)
  • 2020-12-12 20:49

    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.

    0 讨论(0)
  • 2020-12-12 20:50

    Older versions of git have a performance issue with git status - see Ways to improve git status performance 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.

    0 讨论(0)
  • 2020-12-12 20:53

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

    0 讨论(0)
  • 2020-12-12 20:53

    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.

    0 讨论(0)
提交回复
热议问题