Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git for Windows: Difference between Git\bin\bash.exe and Git\usr\bin\bash.exe

Tags:

git

bash

windows

From what I understand bin\bash.exe invokes usr\bin\bash.exe I guess with some options to help manage windows paths but can't find any documentation to indicate that.

All I know is my scripts seem not to work as expected if I have my environment set to use Git\usr\bin\ rather than Git\bin.

A new dev box seems to have this setup:

where bash

C:\Windows\System32\bash.exe

C:\Program Files\Git\usr\bin\bash.exe

I can understand wsl being top but can't understand the second entry if bin/bash.exe is the one I am supposed to use?

like image 697
Alastair Taylor Avatar asked Aug 07 '18 14:08

Alastair Taylor


People also ask

Is git for Windows the same as git bash?

Git is a version control system that lets developers track source code changes during software development. Git Bash is an application for Microsoft Windows, allowing developers to use Git in a command-line interface.

What is the difference between git bash and bash?

Bash is an acronym for Bourne Again Shell. A shell is a terminal application used to interface with an operating system through written commands. Bash is a popular default shell on Linux and macOS. Git Bash is a package that installs Bash, some common bash utilities, and Git on a Windows operating system.

What is the difference between git cmd and git bash?

Git CMD is just like regular Windows command prompt with the git command. It lets you use all of Git features through command line. Useful if you are already familiar with Windows cmd and you only work on Windows. Git Bash emulates a bash environment on windows.

Is git bash necessary for Windows?

You don't need to use Git Bash. It is just conventional, because Git was developed and designed on Linux and most Git users use Linux and using Git Bash on Windows makes it a uniform experience. You can certainly use Git on cmd; just make sure you add C:\Program Files\git\cmd to your PATH .


2 Answers

%windir%\system32\bash.exe = inline bash shell hosted by whatever windows subsystem for linux [ wsl ] environment you have enabled using microsoft store | windows subsystem for linux | | install. An alternative but essentially same result as the separate window that start menu shortcut %windir%\system32\wsl.exe ~ -d Ubuntu launches.

%programfiles%\git\bin\bash.exe -> %programfiles%\git\usr\bin\bash.exe + some automatically injected arguments = inline [ main stdin/stdout ] bash shell provided by git layered on top of windows cmd.exe command prompt environment

%programfiles%\git\git-bash.exe = windows app [ winmain ] bash shell provided by git layered on top of windows cmd.exe command prompt environment

like image 145
myusrn Avatar answered Oct 23 '22 13:10

myusrn


So it appears that:

"C:\Program Files\Git\usr\bin\bash" -li

yields:

Me@MYPC MSYS /usr/bin

and

"C:\Program Files\Git\bin\bash" -li

yields:

Me@MYPC MINGW64 /usr/bin

So to my eyes that implies the EXE are compiled differently.

But in my case the issues I was having with my scripts was purely down to the PATH each exe sets up:

For

"C:\Program Files\Git\usr\bin\bash.exe"

$ where FIND C:\Windows\System32\find.exe C:\Program Files\Git\usr\bin\find.exe

Whereas:

"C:\Program Files\Git\bin\bash.exe"

$ where FIND C:\Program Files\Git\usr\bin\find.exe C:\Windows\System32\find.exe

So my script in the former case was failing with a

FIND: Parameter format not correct

as it wasn't finding the correct version of find.

like image 32
Alastair Taylor Avatar answered Oct 23 '22 12:10

Alastair Taylor