8

While trying to start a git bash window on any folder in my windows 7 machine, the git bash window closes right away.

I do this by clicking on the "Git Bash" option in the context menu.

enter image description here

When I try to start the Git Bash the console window starts temporarily for a few seconds and exits with a 'logout' message.

I tried to go to the Git installed location and run the "Git Bash.lnk" which exits with this message:

D:\DevProgs\Installed\Git-1.7.11\Git>"Git Bash.lnk"
Welcome to Git (version 1.7.11-preview20120710)


Run 'git help git' to display the help index.
Run 'git help <command>' to display help for specific commands.

AD@AYUSMAN /
$ logout

D:\DevProgs\Installed\Git-1.7.11\Git>

Is there something I am doing wrong? I had been able to use Git Bash without any issues on any folder so far.

System Info: Windows 7 64 bit professional edition. Git 1.7.11

8 Answers 8

5

This suddently started happening for me also. I upgraded to Git version 1.9.5 but nothing changed.

The shortcut was using the following command: "C:\Program Files (x86)\Git\bin\sh.exe" --login -i and exiting with this bad-looking guru meditation:

PS C:\Program Files (x86)\Git\bin> .\sh.exe
0 [main] us 0 init_cheap: VirtualAlloc pointer is null, Win32 error 487
AllocationBase 0x0, BaseAddress 0x68570000, RegionSize 0x460000, State 0x10000
C:\Program Files (x86)\Git\bin\sh.exe:
*** Couldn't reserve space for cygwin's heap, Win32 error 0

So I changed the shortcut to launch Bash instead: "C:\Program Files (x86)\Git\bin\bash.exe" --login -i and all was fixed.

Sign up to request clarification or add additional context in comments.

Comments

4

Fixed this by:

  1. Open CMD as Admin
  2. CD to the installation path of GitHub (e.g. CMDPRMPT> CD "C:\Program Files\Git")
  3. Run "git-bash.exe" from command prompt
  4. Right-click the GIT BASH icon on the taskbar and pin it so you can avoid steps 1-3 in the future.

OS Version: Windows 7

GIT version: 2.15.0

Hopefully this helps!

1 Comment

This is just how to put the gitbash icon on the taskbar. That's not at all relevant to the question.
4

Update in 2024

I had an error where my C:\Program Files\Git\ git-bash.exe seemingly wouldn't run at all. It would immediately return and not even take -v to dump the runcoms it loads. But, bash.exe from C:\Program Files\Git\bin worked fine!

I noticed by total chance that a dumpfile was being created ~\mintty.exe.stackdump and on a hunch realized that my .minttyrc was written to the previous day when I changed a terminal setting. Wiping this file fixed git-bash.exe's issue. Apparently there's some bug when customizing the Mingw installed with Git for Windows where it will write to a .minttyrc but crash silently on startup if it doesn't like some settings.

1 Comment

Deleting just the problematic line in my C:\Users\username\.minttyrc file allowed git-bash.exe to launch successfully. Namely, StatusLine=yes. Others have trouble with their column size being too large, e.g. Columns=80000. See also stackoverflow.com/questions/56000157/… and stackoverflow.com/questions/62374053/….
2

just open git-Bash.exe as admin this worked for me

Comments

1

Try git v1.8.4 for windows, it works fine to me.
It seems newer version can't use https git push.

2 Comments

will it not be a problem if I can't use the https push?
@Ayusman I am just give a suggestion, because push via https is a very important feature for me, I am not sure is it important for you.
0

The problem was my Kaspersky antivirus. I had to re-install Git and add the Git exe (and other associated Git executable) to safe list of Kaspersky safe list. It took quitesometime to work, but seems to be working fine now.

Comments

0

That problem, although showing always the same face (git-bash just not starting), can obviously occur due to many reasons. In my case, none of the other solutions helped; I had re-installed Git for Windows a dozen times to no avail. I was using version 2.42.

During those installations, I had chosen mintty as terminal, because the alternative cmd is just not usable IMHO. Finally, I uninstalled Git for Windows again and examined my user profile directory (that Git bash considers to be the home directory). I noticed that there was a .minttyrc configuration file even after having uninstalled Git for Windows.

After having deleted that file and after having re-installed Git for Windows, git-bash was working as expected. Obviously, .minttyrc was damaged to a degree that it prevented mintty (and hence, git-bash) from starting.

That also explains why git-bash may run when started in administrator context, and may not run when started in normal user context: The profile directory is different for each user. Administrator's home directory may contain a valid .minttyrc, while another user profile might contain a damaged one.

Bottom line:

  • When uninstalling (or upgrading) Git for Windows, it may leave damaged .minttyrc files in users' profile directories (that is, in users' home directories from a bash point of view).

  • The damage may prevent git-bash from starting.

  • Hence, if none of the previous solutions helps, just delete the .minttyrc file in the profile directory of the user in whose context git-bash.exe should start; normally, that directory is c:\Users\<username>.

Note that you do not need to uninstall and re-install Git for Windows to see the effect. Please also note that deleting .minttyrc will destroy the settings if you already have configured mintty to your needs. However, that configuration is extremely easy and takes only a few seconds.

Comments

0

Just rename the ".bashrc" (ex: ".bashrc.backup") , in the user folder, solved it for me. this works if the .bashrc file is corrupted, has incorrect settings, or has syntax errors. let me know if it works for you.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.