How to start the MingW console (GitBash) from the command line in Windows?

I am trying to automate my work environment configured using a batch file. I am stuck at the point where I cannot start the MingW64 console from the command line.

start "" "%ProgramFiles%\Git\bin\sh.exe" --login works fine, but it looks like another shell window I'm looking for opens. I will explain this with photographs.

The default cmd style window opens with integrated bash. This window doesn't even resize enter image description here

What I want - enter image description here

I tried to use the start "" "%ProgramFiles%\Git\git-bash.exe" --login -i -c /bin/bash command start "" "%ProgramFiles%\Git\git-bash.exe" --login -i -c /bin/bash , but it seems to quickly close the shell after opening it. If I run the same file from Explorer, the shell does not close automatically.

Here is my complete batch file for reference

 @echo on REM start PHP and MYSQL start "" mysql_server\UniServerZ\UniController.exe start_both REM Open PhpMyAdmin start "" http://localhost/us_opt1/ REM Open Folders start "" %SystemRoot%\explorer.exe "E:\work\" REM Open Git Bash Instance :: in order to open the shell in that path cd E:\work\ :: start "" "%ProgramFiles%\Git\bin\sh.exe" --login start "" "%ProgramFiles%\Git\git-bash.exe" --login -i -c /bin/bash REM start sublime text start "" "E:\Sublime Text Build 3083 x64\sublime_text.exe" 
+5
source share
1 answer

git-bash.exe -i -c "/bin/bash" seems to work better.
This problem illustrates other ways to call git-bash.exe , but completes:

The preferred way to start git -for-windows is using git-cmd.exe :

 c:\git\git-cmd.exe --command=usr/bin/bash.exe -l -i 

This only opens a session in the current cmd, and git-bash.exe opens new windows.

In combination with this question (to open a new console) and this (to avoid two CMD windows), I would use:

 start /b cmd /c git-bash.exe -i -l -c "/bin/bash" 

OP Atif Mohammed Ameenuddin reports in the comments that this works fine:

 start "" "%ProgramFiles%\Git\git-bash.exe" 
+6
source

Source: https://habr.com/ru/post/1238018/


All Articles