3

I have a Windows 10 laptop with SSD, 16GB of RAM, and an i7 processor.

I have read this thread and none of the solutions helped. Git/Bash is extremely slow in Windows 7 x64

I have tried using Git in the following scenarios:

  1. Command Prompt
  2. Git Bash Shell
  3. Visual Studio 2015
  4. Source Tree

All of them are pretty much unusable. For example, before I started typing this question I ran the following command from the Command Prompt:

git flow feature start "Separate_Cash_Incentives"

It has been running for over 10 minutes and has not completed yet.

When I look at my task manager, my CPU is at 10%, my memory is at 40%, and my disk is at 5%.

There are currently 10 "Git for Windows" processes running and all of them say 0% CPU.

How can I fix this problem?

Thanks!

EDIT: It appears that the majority of the slowness happens when creating or merging branches. Just doing a simple commit or push is pretty fast.

Community
  • 1
  • 1
jkruer01
  • 2,175
  • 4
  • 32
  • 57
  • So how much time it takes to merge a branch if you do it manually? Do you have any merge tools set up? Is your repository big, do you have many conflicts in the merge? Are there additional processes while the merge? – max630 Apr 10 '17 at 10:09
  • Where you mention "creating branch", does it also mean checking it out? Creating branch itself cannot be slow, it's basically noop. – max630 Apr 10 '17 at 10:10
  • I use git flow for branching merging. When I say creating a branch I mean using the git flow feature start which creates a new branch with the feature name. The repository is extremely small as far as production applications go. It is an MVC web application with a single project file. When merging there are no conflicts. It also takes 10-20 minutes to complete a merge. – jkruer01 Apr 10 '17 at 11:30
  • what does `echo $HOME` in git bash says to you? isn't it some 'M:\'? – max630 Apr 10 '17 at 16:06
  • @max630 it says /c/Users/jkruer – jkruer01 Apr 10 '17 at 16:42
  • I found the solution here, this [solution](https://stackoverflow.com/a/43762587/8127543) worked for me. – jamuna Sep 17 '18 at 03:28
  • i found the answer here, this [solution](https://stackoverflow.com/a/43762587/8127543) worked for me – jamuna Sep 17 '18 at 03:29

2 Answers2

3

Just for testing, try and

Try and:

  • unzip PortableGit-2.12.2.2-64-bit.7z.exe (if you have a Windows 64 bits) anywhere you want.
    For instance: C:\git\2.12.2.2
  • open a regular CMD console and set a PATH to:

    set PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\
    set PATH=%PATH%;C:\git\2.12.2.2\bin;C:\git\2.12.2.2\cmd;C:\git\2.12.2.2\usr\bin;C:\git\2.12.2.2\mingw64\bin
    

Then type bash -l -i and see if Git is still slow.

The goal is to make sure you don't have any conflicts with other software in your PATH.

Also, try and (for testing) turn out that your anti-virus to see if there is any side-effect here.

Finally, make sure your codebase is on your local drive (not accessed through the network or shared mounted folder)

It remains to be tested if a simple exception rule (for instance on the git installation folder) would be enough for git to run normally (ie, if the AV is set to not check its git installation folder).


It appears that the majority of the slowness happens when creating or merging branches.

Speaking of merge, Git 2.28 (Q3 2020) will include some code optimization for a common case.

See commit 8777616 (19 May 2020) by Andrew Ng (andrewyng).
(Merged by Junio C Hamano -- gitster -- in commit 0739479, 02 Jun 2020)

merge: optimization to skip evaluate_result for single strategy

Signed-off-by: Andrew Ng

For a merge with a single strategy, the result of evaluate_result() is effectively not used and therefore is not needed, so avoid altogether.

On Windows, this optimization can halve the time required to perform a recursive merge of a single commit with the LLVM repo.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I opened the command prompt as an Administrator. I performed the steps that you recommended. When I ran bash -l -i I received the following messages: mkdir: cannot change permissions of '/dev/shm': Permission denied. mkdir: cannot change permissions of '/dev/mqueue': Permissions denied. Then it ran through several lines of listing a folder name -> '/etc/...'. – jkruer01 Apr 10 '17 at 12:21
  • @jkruer01 No need for admin rights: open it as a regular user, and try again. – VonC Apr 10 '17 at 12:24
  • This process is still running. It has been running for 3 minutes 38 seconds so far. Not finished yet. – jkruer01 Apr 10 '17 at 12:24
  • Command finally completed. It took 7 minutes 57 seconds but I am now at a bash prompt. I'll exit and run as a regular user and see if that changes anything. Thanks! – jkruer01 Apr 10 '17 at 12:29
  • running as a regular user, I was able to get to the bash prompt in 47 seconds. A HUGE improvement but still ridiculously slow. – jkruer01 Apr 10 '17 at 12:32
  • Just navigating around in bash prompt is still very slow. I can usually type the entire command before the first letter starts to show up. There is about a 3-4 second delay to get a response to an "ls -l" command. – jkruer01 Apr 10 '17 at 12:35
  • @jkruer01 do you confirm no network paths are involved? What a git status do in a repo when done in a regular CMD (no bash called) – VonC Apr 10 '17 at 12:35
  • yes, the repo is on my local C:. When I ran git status within a local repo from a regular CMD it responded within 1-2 seconds. – jkruer01 Apr 10 '17 at 12:41
  • @jkruer01 OK so the issue is limited to the bash, and its posix sub-shell spawn process... – VonC Apr 10 '17 at 13:03
  • I just disabled my Anti-Virus. I opened a regular CMD prompt (as a regular user) and ran the following command: git flow hotfix start LeaseDisclaimer. I received the following message: " 2 [main] sh 3780 fork: child -1 - CreateProcessW failed for 'C:\Program Files\Git\usr\bin\sh.exe', errno 13 C:/Program Files/Git/usr/bin/gitflow-common: fork: Permission denied" – jkruer01 Apr 10 '17 at 13:14
  • It took approximately 1 minute 34 seconds for the command to complete. – jkruer01 Apr 10 '17 at 13:15
  • @jkruer01 Why C:\Program Files? Could you unzip the portable version in C:\git2.12.2 and adjust your PATh as suggested (system Windows folders and Git folders only) in order to see if the issue persists? – VonC Apr 10 '17 at 13:19
  • @jkruer01 Also: http://stackoverflow.com/q/5851611/6309 (like the last answer for instance) – VonC Apr 10 '17 at 13:20
  • Sorry I closed the CMD prompt where I set the PATH variables because I was running as Administrator. I forgot that it will clear those out when I open a new CMD prompt as a regular user. Let me reset them and try again. Thanks! – jkruer01 Apr 10 '17 at 13:28
  • @jkruer01 I would advice against running anything as Admin. It also make the global Git config differ (between Admin/.gitconfig and yourLogin/.gitconfig) – VonC Apr 10 '17 at 13:30
  • It completed successfully this time, but it took 3 minutes 42 seconds to complete. Here is a screenshot of the CMD prompt. http://imgur.com/a/tQfWu – jkruer01 Apr 10 '17 at 13:34
  • @jkruer01 git flow stil references C:\program Files: you need to check how git flow has been installed. – VonC Apr 10 '17 at 13:36
  • the first time was before I set the PATH variables. Then I set the PATH variables and it is referencing C:\git\2.12.2.2 – jkruer01 Apr 10 '17 at 13:43
  • You can see in the screenshot where I set the PATH variables and it points to the correct location after that. – jkruer01 Apr 10 '17 at 13:43
0

You can try reinstalling git after a complete uninstall and then try to run those commands in git bash.

Brijesh Shah
  • 172
  • 8