Target: "C:\Program Files\Git\git-bash.exe"--cd-to-home Start in: %HOMEDRIVE%%HOMEPATH%
bin/bash.exe
versus usr/bin/bash.exe
Git Bash is a Windows command-line shell that is packaged with Git for Windows. It emulates the bash shell that is familiar to nix-nux users.[2][3] To learn about Git Bash, see Infinite Ink’s Git Bash Is My Preferred Windows Shell and #git-bash Portal.
💡 | Git Bash is useful even if you do not use git. |
To interact[4] with Git Bash and command-line shells in general, humans use a terminal emulator. A terminal emulator can be either a standalone app, for example ConEmu, or integrated into another app, for example Visual Studio Code’s integrated terminal. To view a list of standalone terminal emultors, see Wikipedia’s List of terminal emulators.
ℹ | Terminal emulators are also known as terminals and consoles. |
bin/bash.exe
versus usr/bin/bash.exe
In the sections below, sometimes
bin/bash.exe
is used
and sometimes
usr/bin/bash.exe
is used.
Both of these launch Git Bash
and the only difference — as far as I can tell — is that
bin/bash.exe
executes
usr/bin/bash.exe
as a login shell.
If you install Git Bash with the default Git for Windows set-up options, you will easily be able to launch Git Bash in the Mintty terminal emulator from Windows File Explorer or from a Windows Desktop shortcut.
In Windows File Explorer,
right-click any folder
and choose
Git Bash Here
in the pop-up context menu.
This launches Git Bash in Mintty
with the right-clicked folder as the
working directory.
If you
double click the Git Bash shortcut
on your
Windows Desktop,
it will launch Git Bash in Mintty with your home directory (~
)
as the
working directory.
If you right-click on the default Desktop Git Bash shortcut and choose Properties, you will see something like the following.
Target: "C:\Program Files\Git\git-bash.exe"--cd-to-home Start in: %HOMEDRIVE%%HOMEPATH%
You can change these shortcut properties if you like.
For example,
to start in the C:\
directory, use this:
Target: "C:\Program Files\Git\git-bash.exe"--cd=C:\
To start in a directory specified by an environment variable, use something like this:
Target: "C:\Program Files\Git\git-bash.exe"--cd=%INFINITEINKROOT%
Some
of git-bash.exe
's
command-line options,
such as
,
are discussed in
superuser.com/questions/1104567/how-can-i-find-out-the-command-line-options-for-git-bash-exe.
‼ |
|
The easiest way to set up ConEmu to launch Git Bash is to do the following in this order:
Install Git for Windows, which includes Git Bash.
Install ConEmu.
If you
install these apps in this order,
the following
will
automatically
be
one of the options in ConEmu’s
list.
{Bash::Git bash}
Then all you have to do is choose this option and it will just work.👏
If you need to manually add a ConEmu startup task for Git Bash, follow the instructions at conemu.github.io/en/GitForWindows.html. In March 2021, this command is recommended:
git-cmd.exe --no-cd --command=usr/bin/bash.exe -l -i ^^^^^^^ ^^^^^^^ Note Note
To use Git Bash in VS Code's integrated terminal emulator, do the following two steps.
Follow the Git Bash instructions at
code.visualstudio.com/docs/editor/integrated-terminal.
In March 2021, the VS Code documentation
suggested
including
this[5]
in your settings.json
:
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\git-cmd.exe",
"terminal.integrated.shellArgs.windows": [
"--command=usr/bin/bash.exe",
"-l",
"-i"
]
If the Backspace key
does not work,
set your Git Bash
TERM
environment variable
to
cygwin
or
xterm
.
How to do this
is discussed in
Infinite Ink’s
Git Bash Is My Preferred Windows Shell
in the
~/.bash_profile
section.
To learn about IntelliJ IDEA's integrated terminal emulator, see www.jetbrains.com/help/idea/settings-tools-terminal.html. On that page, there are seven “Shell path” examples, but unfortunately Git Bash is not one of the examples. The following is suggested for Cygwin:
"C:\cygwin\bin\bash.exe" --login -i
Since Git Bash is similar to Cygwin, I tried this:
"C:\Program Files\Git\usr\bin\bash.exe" --login -i
And it worked![5]
Note that I also needed to
set the Git Bash
TERM
environment variable
to
cygwin
or
xterm
.
In
Vim v8.1 and newer, you can launch an integrated terminal emulator with
the :terminal
or :term
command.
On my Windows devices,
these equivalent commands launch
the old Windows shell
called
CMD (also known as cmd.exe and “Command Prompt”).
To launch Git Bash instead of CMD,
typing
this
sequence
within Vim
works for me.
Esc :term bash -li
To exit this integrated Vim terminal emulator, I type the following sequence of commands.
exit :q
ℹ |
|
To use Git Bash with
Microsoft’s Windows Terminal,
which is also known as wt.exe
,
follow the instructions at
github.com/microsoft/terminal/blob/main/doc/user-docs/ThirdPartyToolProfiles.md.
In
April
2021,
this[5]
JSON fragment is
suggested:
{
"name": "Git Bash",
"commandline": "C:\\Program Files\\Git\\bin\\bash.exe -li",
"icon": "C:\\Program Files\\Git\\mingw64\\share\\git\\git-for-windows.ico",
"startingDirectory": "%USERPROFILE%"
}
You may want to change the highlighted line above to this:
"commandline": "C:\\Program Files\\Git\\usr\\bin\\bash.exe -li", ^^^^^ Note
This may be better because…
bin\bash.exe
calls
usr\bin\bash.exe
and
it
should
use less
memory
to directly call
usr\bin\bash.exe
;
and reasons discussed in conemu.github.io/en/GitForWindows.html.
On the other hand, it may or may not be better because of reasons discussed in…
For more about this, see
Microsoft’s
Windows Terminal General Profile Settings.
If you have thoughts about what is the best way
to launch Git Bash in Windows Terminal,
please comment
below.
For more about Git Bash, see Infinite Ink’s…
bash.exe
with the -i
command-line option, it means you want to be able to interact with the Bash shell.C:\Program Files\Git\
).Your public comment or question might immediately improve this page or help me to (eventually) improve this page.