windowsgit-bash

git bash suddenly slow on every command not only git command


I have git bash in WIN 10. Since last week suddenly every command (ls, cd, git, ...) runs very slow, even ctrl-c. After type a command it pauses, and then shows result, before command completes, it pauses another while. I remembered last week there was a 3D Graphics GPU something in notification corner during that time. I checked that I don't have GPU in this PC, and it is GeForce 630 with a 2017 driver. (heard that AMD driver can cause such problem).


Solution

  • If you have encountered some Git Bash weird behavior, and shell/terminal works not as fast as before, I'd recommend starting from step 1 or 2


    1 Safe Mode

    Boot in Safe Mode & see if it helps

    Possible results: if Git Bash works faster in this mode, it means 3rd party service or some recently installed software might causes those issues 4 u. Or it could be a bloated git repo/misconfiguration in git config

    if this helps you can proceed to step 4 (where I explain how to find which service might be the issue)


    2 Modify your Git Bash prompt (most effective as the practice shows)

    Overcomplicated shell prompts might slow down your terminal

    🔧 Edit your ~/.bashrc or ~/.bash_profile:

    export PS1='\u@\h:\w\$ '
    

    📖 Read more here:


    3 Recommended Git Bash config

    Execute the following commands:

    git config --global core.preloadindex true
    git config --global core.fscache true
    git config --global gc.auto 256
    

    In a nutshell:

    Citation from git help config (this opens a documentation page in your web-browser)

    core.preloadIndex Enable parallel index preload for operations like git diff This can speed up operations like git diff and git status, especially on filesystems like NFS that have weak caching semantics and thus relatively high IO latencies. When enabled, Git will do the index comparison to the filesystem data in parallel, allowing overlapping IO’s. Defaults to true.

    core.fscache Enable additional caching of file system data for some operations. Git for Windows uses this to bulk-read and cache lstat data of entire directories (instead of doing lstat file by file).

    gc.auto When there are approximately more than this many loose objects in the repository, git gc --auto will pack them. Some Porcelain commands use this command to perform a light-weight garbage collection from time to time. The default value is 6700. Setting this to 0 disables not only automatic packing based on the number of loose objects, but also any other heuristic git gc --auto will otherwise use to determine if there’s work to do, such as gc.autoPackLimit.

    Verification step:

    git config --list
    

    Result should be (if you set all of them):

    core.preloadindex=true
    core.fscache=true
    gc.auto=256
    

    4 Services

    if Step 1 wasn't useful, most likely you can skip this step

    1. Win + R, type msconfig, hit Enter
    2. Go to the Services tab
    3. Check “Hide all Microsoft services”
    4. (Optional recommended) take a screenshot before and after to help you in the future if it works
    5. Disable non-Microsoft services - e.g mouse/keyboard software, monitoring tools (such as MSI Afterburner), sync tools (OneDrive, Dropbox), and other GPU overlays
    6. Reboot and test Git Bash

    If it helps:


    5 Antivirus & Defender exclusions

    Many AV tools might slow down not only your PC but other software too such as Git Bash by doing more extra scans during your command execution.

    Try adding this files into your exclusion list C:\Program Files\Git\bin\ folder:

    🔐 Windows Defender

    1. Open Settings
    2. Go to Privacy & Security => Windows Security => Virus & threat protection
    3. Click Manage Settings => Scroll down to Exclusions
    4. Add the .exe files listed above

    6 Git Bash unstill and clean install

    1. Uninstall Git Bash, clean your windows cache, and other temporary files
    2. Delete old configs at: %USERPROFILE%\.gitconfig, %ProgramFiles%\Git
    3. Download page for Git Bash

    Go for default config during installation & avoid PATH overrides

    Show hidden files/folders on windows:

    1. Win + E - opens File Explorer
    2. At the top right corner of the File Explorer click arrow ⬇️ (down to expand the menu) or in Windows 11 it is three vertical dots instead
    3. Click Options
    4. Tab View
    5. Under Files and Folders, find Hidden files and folders
    6. Select Show hidden files, folders, and drives
    7. Click Apply and Ok

    Now hidden you should see all files & folders.


    7 Event Viewer Logs

    it can useful if you can easily replicate slow terminal

    If you still experience this misbehavior

    You can find DLLs, conflicts with GPU, permissions issues, antivirus software, or some other useful information.

    It is also worth checking Windows logs: - Application logs - System logs

    Have a look at the column called Level (Error) after trying to run the commands (that freeze/slows down your git bash). Look at the date and time column to see the most recent errors.

    Then Win + R => eventvwr, it is another way to open Event Viewer where you might find warning/error (the one that makes Git Bash or your terminal to freeze) Error example from Event Viewer (you could use the error message and Event ID to Google the problem): event viewer image


    8 GPU Driver rollback or its update

    1. Win + X
    2. Open Device Manager
    3. Expand Display Adapters
    4. Right-click your GPU (e.g., GeForce GT 630) => Properties
    5. Go to the Driver tab
    6. Try

    See How to Stop Windows 10 Apps From Launching at Startup

    9 Few more things to try:

    Uninstalling any recent software

    control panel ➡️ programs and features - find and delete most suspected software you might think of you installed when this freeze/slow terminal appeared.


    🧪When steps from above don't help

    Restore point (⚠️ it can delete some of your data)

    See Recovery options in Windows

    Reinstalling windows

    Windows 10 website => Create Windows 10 installation media section.


    🧠 Helpful Resources

    1. 🔗 Git Bash is extremely slow on Windows 7 x64
    2. 🔗 What is git gc?
    3. 🔗 Why is core.preloadindex false by default?