105

I installed Git on my Windows 10 a couple of months ago. It worked well for some time. But now, it's running very slow.

The git status command takes 7 seconds to execute, and git stash takes many minutes for stashing (even if there is nothing to stash). Also, I would like to point out that git status prints the result instantaneously, but I can not enter a new command for a few seconds, as shown in the image below.

The screen is stuck like this for 7 seconds

I have tried solutions to similar problems like link1, link2, etc., but none of these have worked.

P.S.: I use Windows Defender antivirus, and it is NOT making my Bash slow. Also, cmd takes more time to execute git commands while git bash takes longer to run any command.


Update: I have switched to Ubuntu, and therefore, I don't use Windows presently. So, there is no way I can check if any of the solutions work for me. I have accepted the answer provided by @pschild since it has the most upvotes and seems to have worked for many people.

Rohan Bhatia
  • 1,590
  • 2
  • 13
  • 31
  • 5
    It looks like there problem lies in your bash prompt setting. Try setting `PS1='$ '` so that whatever fancy prompt setting is deactivated, then see if it is still slow to you. – holygeek Mar 19 '17 at 15:38
  • @holygeek, thanks it helped.. Now git status takes about 3-4 sec rather than 7. But its still slow, right? – Rohan Bhatia Mar 19 '17 at 19:23
  • Is it only GIT? Are you on a network drive, or a SSD? Do you observe random lag while using your computer? – Guillaume F. Mar 31 '17 at 01:07
  • yes it is only GIT, everything else is fine. I m not on a network drive or SSD – Rohan Bhatia Mar 31 '17 at 07:56
  • It's been a long time since I booted windows, but try the `id` command. If that takes a long time, ... I forget how you fix that, but it's at least something I've seen – jthill Mar 31 '17 at 14:35
  • 1
    _As a bounty newbie I screwed up big time on both bounty reason and custom message_ Disabling AMD Radeon driver solved my issue but I am really wondering on *why* part.Would appreciate an answer which focuses on that. – Lafexlos Jan 22 '18 at 20:57
  • @Lafexlos Still, I have seen your bounty, and proposed [an answer below](https://stackoverflow.com/a/48390680/6309). – VonC Jan 22 '18 at 21:45
  • In my case, a shell on a slow network folder. – Michael Oct 07 '19 at 18:06
  • I was using Git-2.28 which was slow, I downgraded it to Git-2.26.2-64-bit, It is much faster. I am not sure why. – Vinayak Dornala Oct 20 '20 at 18:47
  • This issue is most likely _**completely unrelated**_ to Git Bash. (At least in my case `cmd.exe` - _and_ other applications are being ridiculously sluggish.) – Henke Nov 24 '20 at 06:28

19 Answers19

78

I recently ran into the exact same issue. After trying all the advice from this thread and a lot of other threads, I finally found a solution here, respectively in the linked issue here.

Disabling AMD Radeon graphics driver in the Windows device manager and switching to integrated Intel HD graphics worked for me - for whatever reason.

Hope that helps!

In my case, I found sh.exe shell to be significantly faster than bash.exe. You can find sh.exe in git_install_dir/bin.

Hope this helps people having this issue while only having integrated Intel HD graphics!

pschild
  • 2,578
  • 1
  • 17
  • 26
  • 2
    dude, you just fixed my problem, thank!. I have no idea why this is happening, but disabling AMD driver fixed it for me also. I went crazy trying to figure out wth was going on :). – DVM May 25 '17 at 08:53
  • 1
    Man, thank you so much. I've spent the whole day to make this running. I would never see this. – Ante Braovic Jun 27 '17 at 07:50
  • 1
    Spent 5 days. and finally this resolved the issue. :+1 – Swagat Swain Aug 29 '17 at 03:20
  • 1
    Yes this solved the issue also for me.. but wat? is it a bug on the AMD driver? – bySamo Oct 16 '17 at 14:57
  • 9
    Anyone have any ideas why disabling the AMD driver helps? I'm struggling to make the connection between how the driver was affecting the performance of git bash. If I had to guess I would assume that maybe it has someone to do with the rendering of the content in the git bash window. Otherwise, as suggested @bySamo is it a bug in the driver? The only connection I can make between the AMD driver and the git bash program is the rendering of the window. Any thoughts? I guess it could be something to do with the requests they make. – Lsakurifaisu Oct 30 '17 at 11:34
  • 1
    My suggestion is to open a support ticket for the AMD driver. I did the same a while ago for a problem in the Intel HD driver (not about Git, something completely different) and Intel could reproduce the problem and is working on a solution now. Probably the producer of the hardware and drivers has a much better idea about finding out what is happening there **if** you can make the problem reproduceable for him by providing all necessary hardware, sofrtware and driver version information. – kriegaex Jan 27 '18 at 09:35
  • 9
    The bug is that the AMD driver delays process destruction by 1 second per process. (I identified the bug using Process Monitor.) Updating the driver fixes this issue. – nyanpasu64 Jun 19 '18 at 22:52
  • I've been using super-slow Git for a week now b4 I finally saw this answer. Seeing git status finally complete in a few milliseconds is almost magical to me XD – takanuva15 Jun 28 '18 at 02:38
  • Thank you so much for the suggestion of using sh.exe! I just started using git recently and was hating it because the bash.exe was so slow. This has made me a total convert now. :) – Miniversal Jul 11 '19 at 12:18
  • 1
    I didn't have the AMD driver mentioned, but I did have AMD FirePro, however disabling that didn't seem to make a difference. Using sh.exe however made a world of difference. So much better! Thanks – Craig Brett Jan 21 '20 at 14:08
  • Using sh.exe even with the AMD driver enabled solves the issue for me – anurupr Jan 26 '20 at 17:35
  • 1
    I don't have AMD Radeon graphics driver on my windows 10, Still git commands are slow – Vinayak Dornala Oct 01 '20 at 16:28
  • In my case it is the _command prompt_ that is sluggish. I reinstalled my drivers, as follows. I googled for "26.20.11008.1007" 1909 site:ftp.hp.com and found ftp://ftp.hp.com/pub/softpaq/sp101501-102000/sp101604.html. To download the driver I replaced the suffix .html with .exe: ftp://ftp.hp.com/pub/softpaq/sp101501-102000/sp101604.exe. It was worth a trial but unfortunately it did not work - the sluggishness is back (after a few days). – Henke Nov 15 '20 at 15:24
  • Turning off Windows Defender Firewall did not help, so I turned it back on. – Henke Nov 23 '20 at 07:47
  • I _thought_ I nailed it yesterday, by following the advice at https://answers.microsoft.com/en-us/windows/forum/windows_10-performance-winpc/how-to-stop-the-windows-compatability-telemetry/3e6f469a-e527-4744-a313-cb52030b3461. But sadly, the sluggishness persists. I cannot even reproduce it - it tends to happen when I haven't used my laptop for several hours, typically every morning. (I may have to give up!) – Henke Nov 24 '20 at 06:43
  • Today I am trying [disabling hardware acceleration](https://community.amd.com/t5/drivers-software/the-method-to-completely-disable-hardware-acceleration-in/td-p/253565). If this does not help either, the next thing to try is a [Clean Install of AMD Graphics Drivers](https://community.amd.com/t5/drivers-software/clean-install-amd-graphics-drivers/td-p/296676). – Henke Nov 24 '20 at 09:52
  • _**Nothing**_ I have tried so far has helped. I guess the fact that I have an HDD instead of an SSD might have something to do with the sluggishness, but I have no intention to by an SSD to my shitty slow (and not so new) laptop ... I even tried setting the pagefile to 0 MB (no pagefile at all), but that did not help either. – Henke Dec 07 '20 at 15:01
  • I just looked into my Recycle Bin and noticed it contained 3.5GB of files. I have now deleted them all and restarted my computer. Also, in the Recycle Bin Properties I changed the Custom size: > Maximum size (MB): to 100. Will see in a few days if this helped or not. Note: if I find a solution, I intend to remove all of the above comments. They are intended to be here _temporarily_ only. – Henke Dec 07 '20 at 16:37
  • Emptying the Recycle Bin did not help. Not sure what to try next? Admittedly, I haven't tried the [Clean Install of AMD Graphics Drivers](https://community.amd.com/t5/drivers-software/clean-install-amd-graphics-drivers/td-p/296676), but somehow I doubt it would help? – Henke Dec 10 '20 at 07:25
  • In Device Manager I just turned off the driver for `GPU 0`, _AMD Radeon R4 Graphics_ after reading about `GPU 0` and `GPU 1` at https://helpdeskgeek.com/help-desk/why-dwm-exe-causes-high-cpu-usage-and-how-to-fix-it/. In Task Manager `GPU 1` corresponds to AMD Radeon 520 and does not seem to eat any CPU at all. Will leave it running for now. – Henke Dec 12 '20 at 15:55
  • Today I tried [AppAudioConfig](https://www.nirsoft.net/utils/app_audio_config.html) to help me remove the registry key that allows _Console Windows Host_ to play sounds: right-click `Console Windows Host` > `Open In RegEdit` and I deleted that key in the registry. Before: https://i.imgur.com/YyI3Wec.png. After: https://i.imgur.com/EGCSZ8F.png. I intend to report back in a week or so to tell whether this was the solution. – Henke Dec 18 '20 at 13:43
  • 1
    git-cmd.exe was significantly faster for me – JohnP2 Dec 30 '20 at 20:19
  • @bySamo In my case, I disabled NVIDIA GPU rather than AMD. Hence, it is not necessarily an AMD bug. This worked, but have no idea why. – Alex Fainshtein Jan 01 '21 at 03:25
  • Thanks @JohnP2! git-cmd.exe is relatively faster for me. But still slower than expected. For eg, commands like cd work instantly but not "git branch" – Rohit Rokde Sep 21 '21 at 22:14
  • As of February 2022, I hav _still_ not figured out what causes sluggishness in my `cmd.exe` (the command-line in Windows). Maybe it is my browser **Pale Moon**? However, I am now using the quick-fix of simply closing and reopening `cmd`. And since I have [Clink](https://mridgers.github.io/clink/) installed, this works rather painless. – Henke Feb 08 '22 at 16:46
  • Same problem as of May-22. This solved the problem for me. – Daneel Olivaw May 12 '22 at 09:37
68

For me, the solution was to set the HOME variable to my user directory (per this answer). To do this (at least on Windows 7):

  1. Right-click on "Computer" in file explorer.
  2. Open Advanced System Settings.
  3. Open Environment Variables
  4. Under System Variables, click "New..."
  5. Enter "HOME" for the variable name and the path to your user directory for the value (for example "C:\Users\jdoe").

See also the answers to this related question.

Paul Wintz
  • 2,168
  • 1
  • 17
  • 30
16

I had the same problem once and what I found is that the issue for me was with __git_ps1, basically a variable that includes status informationlike branch name, detached head state, in the git dir, in a bare repo, in the middle of cherry picking or rebasing or merging.

In order to speed up your git bash, go to $GitHome\etc\profile and comment out the if-then where __git_ps1 is added to PS1.

Anyway the information that you are commenting out are quite useful, expecially if you are at the beginning with GIT. Here is a faster version, found on the internet and used by me quite succesfully on my system:

fast_git_ps1 ()                                                                              
{                                                                                            
    printf -- "$(git branch 2>/dev/null | grep -e '\* ' | sed 's/^..\(.*\)/ {\1} /')"    
}                                                                                            

PS1='\[\033]0;$MSYSTEM:\w\007                                                                
\033[32m\]\u@\h \[\033[33m\w$(fast_git_ps1)\033[0m\]                                         
$ '     
rakwaht
  • 3,220
  • 1
  • 25
  • 42
  • 3
    I meant yes the ps1 changed but git is still slow – Rohan Bhatia Mar 31 '17 at 20:09
  • 3
    On my environment, I had to edit the `$GIT_HOME/etc/profile.d/git-prompt.sh` and remove the line `PS1="$PS1"'``__git_ps1``'` (~line 31). This worked like a charm. – bobbel Aug 06 '19 at 14:21
  • 1
    I just did PS1='$ ' and that made it run much faster on Windows 10. – Don Smith Aug 18 '20 at 20:30
  • Wish there could be multiple accepted answers. It seems like there are multiple issues that can cause performance problems with git bash. Some issues cause commands like git status to take multiple seconds to execute. Other issues cause a delay in returning to the prompt after commands execute. It seems like most of the various completely unrelated answers here helped somebody. For me, the __git_ps1 fix did the trick. – harperska Sep 26 '20 at 00:31
  • 2
    After hours and hours of testing ... graphics drivers, HOME environment variable settings, start git bash as administrator, nothing helped. But changing the PS1 prompt in my `/etc/profile.d/git-prompt.sh` to use a fast_git_ps1 function, it promptly started to speed up. Omitting the __git_ps1 part of the prompt even made it instantly, but the useful branch information was missing then.... – devnull69 Nov 18 '20 at 10:25
  • 2
    I have one that's much faster. The core issue here is largely based on the fact that it's forking multiple processes every single time it's generating the prompt in the `PS1` variable. The solution is to use pure bash. See gist here (and my modified version which leverages `PROMPT_COMMAND`): https://gist.github.com/Ragnoroct/c4c3bf37913afb9469d8fc8cffea5b2f – patricknelson Dec 15 '20 at 04:43
  • 1
    Indeed. Run ```__git_ps1``` to see how much delay it is adding to your PS1 prompt. - I get 2-3 seconds. Exacerbated by HOME being on a network. To get almost instant PS1 updating I moved my HOME off network AND used a faster git branch script (no forking) from here: https://gist.github.com/Ragnoroct/c4c3bf37913afb9469d8fc8cffea5b2f – spechter Oct 06 '21 at 02:21
12

In response to Lafexlos's bounty:

Disabling AMD Radeon driver solved my issue but I am really wondering on why part.
Would appreciate an answer which focuses on that.

As to why:

Issue 1070 reports.

Bringing up the Radeon settings GUI and clicking on something while waiting for the bash prompt immediately releases something and makes it appear - weird.

AMD was contacted but no response...

This project reports:

But all of the graphic (terminal) output has to be displayed via those drivers.
They (the drivers) get their hooks into all parts of the system with hidden interrupts and time outs and goodness knows what. Shudders..

Issue 1129 adds:

Starting with Windows 7 (maybe Vista?) the console had the ability to display itself via DirectWrite, which is build on top of Direct3D, which is heavily dependent on driver implementations of DirectX API.

As a former NVIDIA employee who worked directly on nvd3dum, nvwgf2umx and nvapi I can tell you we were rather skeptical of the wisdom of this decision.
Seems AMD should have been more skeptical, perhaps their driver quality would have been better.

Community
  • 1
  • 1
VonC
  • 1,129,465
  • 480
  • 4,036
  • 4,755
  • I appreciate your effort to write up an answer but [top voted answer](https://stackoverflow.com/a/43762587/3134251) already has these link in it so unfortunately this doesn't add anything new, at least for me. – Lafexlos Jan 23 '18 at 03:28
11

Try again with:

  • the latest Git for Windows you can find, like PortableGit-2.12.1-64-bit.7z.exe (unzip it anywhere you want, no setup)
  • then in a CMD session, set your PATH with:

    set G=c:\path\to\latest\git
    set PATH=%G%\bin;%G%\usr\bin;%G%\mingw64\bin
    set PATH=%PATH%;C:\windows\system32;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\
    
  • set your HOME in that same CMD session

    set HOME=%USERPROFILE%
    
  • Finally, type bash, and see if any Git operation is still slow.

VonC
  • 1,129,465
  • 480
  • 4,036
  • 4,755
  • will I have to uninstall my last version version of git? It was also 2.12.1 but that wasn't portable git – Rohan Bhatia Mar 27 '17 at 15:24
  • @RohanBhatia No; this is a portable version: just uncompress it anywhere you want. You can have multiple version of Git that way. Only your PATH needs to be adjusted. – VonC Mar 27 '17 at 16:04
  • @RohanBhatia Does your PATH include only Git and System32 Windows folders? And is your view located in drive C:\? (or is it accessed through a shared network path?) Does git status takes a long time in a CMD session? (a s opposed as a git bash session) – VonC Mar 27 '17 at 17:28
  • you can see my path variables and other environment variables [here](http://imgur.com/a/oJxDd). Not clear on what you mean by view being located in drive c, but my program files and everything else is in [drive C](http://imgur.com/a/5GUgH). Yes, unfortunately git status takes almost as long to execute git status or any other git command. – Rohan Bhatia Mar 27 '17 at 19:22
  • @RohanBhatia no need for environment variable Windows. Simply open a CMD, type the '`set`' commands I mentioned, cd to your view, and try a git status there (no bash needed) – VonC Mar 27 '17 at 19:45
  • I did open cmd and used those set commands and still git status took 3 secs like i wrote earlier in my first comment – Rohan Bhatia Mar 28 '17 at 06:28
  • @RohanBhatia can you copy the result of the command set PATH (from your CMD where you typed those set commands)? – VonC Mar 28 '17 at 06:30
  • [here](http://imgur.com/a/SAjdi) is what it looked like. See git status was slow enough for me to snip the result from the screen.. – Rohan Bhatia Mar 28 '17 at 07:05
  • @RohanBhatia I see your installation path for Git is on F:\. Try instead uncompress https://github.com/git-for-windows/git/releases/download/v2.12.1.windows.1/PortableGit-2.12.1-64-bit.7z.exe on the C:\ drive, not F:\ drive. – VonC Mar 28 '17 at 07:07
  • No luck.. [Git status](http://imgur.com/a/L2fOU) still takes equal time as before – Rohan Bhatia Mar 28 '17 at 07:15
  • @RohanBhatia How about trying git status in an actual Git repo (on the C:\ drive)? `cd /C/path/to/a/git/repo` – VonC Mar 28 '17 at 07:16
  • git status is still as slow. Even cd takes more time than usual. – Rohan Bhatia Mar 28 '17 at 07:21
  • @RohanBhatia Does a cd done in the CMD session (ie without typing bash, ie not in a bash session) slow as well? Is the git status done in that CMD session (ie no bash) slow as well? – VonC Mar 28 '17 at 07:22
  • No cd executes just fine on cmd without bash.. but git status is still slow on cmd(might be slightly faster).. So to test I just wrote git stash in a git repo with no extra changes over a commit. And it took 1 min for git stash to tell "No local changes to save". in cmd without bash – Rohan Bhatia Mar 28 '17 at 07:26
  • even when I use autocomplete(pressing tab) to complete a branch name while using git checkout in cmd with bash, it takes 10 seconds to execute that – Rohan Bhatia Mar 28 '17 at 07:29
  • @RohanBhatia forget bash for now: the fact it is slow in a CMD session, without typing bash, means something on Windows slow it down: typically an anti-virus or firewall. – VonC Mar 28 '17 at 07:32
  • but I am using windows defender nothing else – Rohan Bhatia Mar 28 '17 at 07:33
  • Can you install and open Process explorer, and see if you have any process which might hog a lot of CPU? (https://technet.microsoft.com/en-us/sysinternals/processexplorer.aspx) – VonC Mar 28 '17 at 07:35
  • I dont think so .. [This](http://imgur.com/a/DmJ6P) is what process explorer show – Rohan Bhatia Mar 28 '17 at 07:39
  • @RohanBhatia even when sorting by CPU? – VonC Mar 28 '17 at 07:40
  • yep sorting by cpu shows 80-90% for systemidleprocess – Rohan Bhatia Mar 28 '17 at 07:42
  • @RohanBhatia OK: can you show me the result of `git config --show-origin -l`, to see if there is some git configuration that could be problematic? – VonC Mar 28 '17 at 07:51
  • @RohanBhatia then try again after applying the configs listed in http://stackoverflow.com/a/24045966/6309 – VonC Mar 28 '17 at 07:53
  • Its time for my class, I will be available after 5 hrs. Thnx for helping me – Rohan Bhatia Mar 28 '17 at 08:02
  • I don't know if this is related but once I reinstalled git and then it was working fine until I restarted my laptop.. – Rohan Bhatia Mar 28 '17 at 08:31
  • @RohanBhatia It should not matter, but you can try that again, and use the Git setup https://github.com/git-for-windows/git/releases/download/v2.12.2.windows.1/Git-2.12.2-64-bit.exe, to see if a Git used through that installation improves anything (before restarting the laptop) – VonC Mar 28 '17 at 08:39
  • It didn't when I reinstalled it again this time. – Rohan Bhatia Mar 28 '17 at 10:38
  • @Henke Regarding git bash alone, did you try it with a simplified PATH and Git 2.29 (released yesterday)? https://github.com/git-for-windows/git/releases/tag/v2.29.0.windows.1 – VonC Oct 20 '20 at 10:11
  • @Henke OK. I would be curious to know if the SO community has some solution for you, if you were to describe your case in its own separate question. – VonC Oct 20 '20 at 12:55
  • @Henke Is it with Git for Windows 2.29.0 or 2.29.2? – VonC Nov 15 '20 at 14:57
7

I had same issue on Windows 7 and Window 10, while using the git bash, any command that I run would take considerable time to execute. Finally after many of head breaking trials, found that issue was due to not running my git bash exe as administrator,

Steps

  1. Right click on git bash exe.
  2. click on 'run as administrator'
  3. type in commands like cd /c/

hope this helps!!!!

Bsquare ℬℬ
  • 4,333
  • 11
  • 23
  • 43
Pramod C V
  • 83
  • 2
  • 8
4

Is your PATH full of junk? Simple commands were taking 20 seconds or more for me sometimes until I removed unnecessary things from my PATH.

Windows: echo %PATH%

Search "edit environment variables" to change.

Other: echo $PATH

Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
Philip Rego
  • 460
  • 4
  • 19
  • 31
  • 1
    on windows this is `set path` btw. – 1mike12 Feb 03 '18 at 21:58
  • https://superuser.com/questions/1070994/intelr-management-engine-components-dal-in-envoirement-variable also want to reference this one here. I think cleaning especially the intel stuff, made my shell faster – Joel Aug 22 '18 at 06:33
  • On a different Win7 AD computer it's taking 2 seconds every time I press enter. CMD works fast. MinGW, Cygwin slow. Intel graphics. Tried all the answers, driving me crazy. – Philip Rego Nov 21 '18 at 21:47
4

Tried everything above that made any sense to me, did not help.

Finally I seem to have fixed the issue. Turned out, Git Credentials Manager for Windows tried to contact my domain controller (that is out of reach since I'm out of the office), and that caused a great delay (30+ seconds) each time I wanted to e.g. git checkout.

To fix this, just had to disable the Credentials Manager completely, now everything's reasonably fast. This is how to disable it: How do I disable Git Credential Manager for Windows?

Hope this helps the desperate ones, cheers!

Kostiantyn Ko
  • 892
  • 7
  • 10
3

I have a similar problem but only when I ran git bash as a normal user, when I started git bash as an Administrator all commands ran really fast.

In my case it turned out that the problem was caused by F-Secure antivirus. I added directory containing git.exe to the list of excluded directories (excluded from scanning) and it solved this problem for me.

How to exclude directory: https://community.f-secure.com/t5/Business/Excluding-objects-from-Real-Time/ta-p/66013

Excluded locations window as of version 21

dodbrian
  • 1,114
  • 16
  • 13
csharpfolk
  • 3,996
  • 23
  • 27
3

Adding process exclusion for bash.exe, cmd.exe and conhost.exe in Windows Defender Exclusions list apparently solved the issue for me on Windows 10 64bit.

mark
  • 27
  • 1
2

For me, the problem was in the installed software Strawberry Perl.

I was using next open-source software for Windows 10:

  • OpenSSH
  • Putty
  • Git for Windows
  • Qt 5.12.6

But, the installator Qt 5.12.6 prompts you to install Strawberry Perl. It seems like this package is needed to automate the creation of software deployment scripts. Strawberry Perl have more open-source software besides the Perl. But in reality in 99% of cases Strawberry Perl installation is unnecessary.

Before uninstall Strawberry Perl, my PATH variable became like this:

PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Program Files\PuTTY\;C:\Strawberry\c\bin;C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin;C:\Users\stepanov_sm\AppData\Local\Microsoft\WindowsApps;

After uninstall Strawberry Perl, my PATH variable became like this:

PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Users\stepanov_sm\AppData\Local\Microsoft\WindowsApps;C:\Windows\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Program Files\PuTTY\;

May be, Strawberry Perl overlap binaries/scripts from Git for Windows. Before uninstall Strawberry Perl, the command git --version executed within 45 seconds! After uninstall Strawberry Perl, the command began to be executed instantly.

Xintrea
  • 381
  • 3
  • 11
  • I looked into each possible solution reported here - most didn't apply or didn't help. I have Strawberry Perl installed (compiling Qt), and I *think* this was the change that fixed my problem. The slowness is actually in 'sh.exe'. Git invokes it - so I was seeing slowdown in both opening a shell as well as invoking 'git'. The AMD driver change didn't apply to me (I have an NVidia graphics card). Things in .bashrc, .bash_profile, /etc/profile were not it, as I tested with empty ones. My AV already had the Git dir excluded. It seems removing C:\Strawberry\c\bin from my PATH was the fix. – Keithel Oct 07 '21 at 15:44
1

Commands like pull, push, etc. seemed to take forever on git bash. Trying on git windows command line prompted github authentication was necessary (web browser/personal token). On authentication, commands started working fine on git windows and git bash as well.

Issue: https://github.com/git-for-windows/git/issues/3284

1

Upgrading to Windows 11 resolved this problem for me. Git console is now as fast as a native command prompt or powershell console. So, if

  1. You are peeved enough about the slow git console, and
  2. Your system is a personal computer that meets the upgrade 11 requirements,
  3. You don't mind these changes/deprecations,

I say give it a try.

Sahil
  • 499
  • 4
  • 13
1

It may be due to the default PS1 configuration of git-bash. It's easy to test.

Check PS1

printf "$PS1\n"

which should output something like

\[\]\[\]\u@\h \[\]$... \[\]\w\[\]`__git_ps1`\[\]$

the culprit may be __git_ps1, let's investigate

time __git_ps1
time __git_ps1
 (main)
real    0m0.290s
user    0m0.015s
sys     0m0.030s

We can change our PS1 to something simpler (but faster)

time git rev-parse --abbrev-ref HEAD 2> /dev/null
main

real    0m0.118s
user    0m0.000s
sys     0m0.031s

by adding the following to our .bashrc

# Use simpler git ps1
PS1="$(sed 's@`__git_ps1`@ (`git rev-parse --abbrev-ref HEAD 2> /dev/null`)@' <<< "$PS1")"

This approach is much better than modifying the prompt/ps1 stuff that is bundled with git-forwindows.

while we are at it I would also recommend adding

# Delete git for windows PS1 newline
PS1=$(sed 's@\\n@@g' <<< "$PS1")

which gets rid of the extra newline that causes the first line of less of output to be scrolled off screen when exiting the pager

CervEd
  • 1,682
  • 18
  • 18
0

Disclaimer: Not a fix. But quick workaround.

For some reason after my computer updated-- I didn't have Git bash on my computer so I had to redownload the new one 2.19.2.windows.1 and I had the same issue with every execution taking 5-7 seconds.

I didn't have time to look into all of the links and disable graphics drivers and what not. But I had Git shell installed with Github on my computer and I pulled that up (Windows PowerShell) and I could run everything on there I needed immediately.

dko
  • 139
  • 7
0

I was running Windows 10 as a virtual machine (using VMware fusion), and for me, changing from 1 to 2 processor cores in the virtual machine setup (which I discovered was the recommended minimun anyway) fixed the problem. The comment by @chunk_split on @rakwaht's answer points in the same direction (i.e. an issue with concurrent threads or processes slowing things down).

Otto G
  • 570
  • 6
  • 14
0

I have been strugling with git bash since 2 months because my colleauge( root problem) told me to store git credentials and I don't know what happend to windows 10 but it screwed up. What I have noticed that whenever it starts it is checking the connection to domain server. here goes my solution. I have removed from these arguments from properties -> start at: %HOMEDRIVE%%HOMEPATH%.

Start -> Search Git Bash -> Open Location of File -> Git Bash -> Right Click -> Properties -> Direct Access -> Start At and remove it whatever you have there.

enter image description here

kamboj
  • 371
  • 4
  • 17
0

For me, the solution was to set the HOME environment variable to my Users folder.

Go to Start - type "environment" - Select "Edit environment variables for your account"

In the top list, check if HOME variable is there. If it's there, change it's value. If it's not there, click on New....

The Variable name will be HOME and Variable value will be path for example C:\Users\<username>.

The reason why this helped to me is that by default, the Home directory in my case, was pointing to shared network drive. This was slowing down the GIT, because it was connecting to that network drive.

Martin819
  • 351
  • 1
  • 6
  • 24
0

For me, what fixed was:

  1. Update git bash (version 2.34.1+)
  2. Run as Admin (so it will run all post-install scripts)
  3. Done

After this, my git bash was opening very fast.

Luan Persini
  • 53
  • 1
  • 4