DEV Community

dpm_bush
dpm_bush

Posted on Originally published at sshflow.com

Bash on Windows: Choose Git Bash or WSL

If you want to run Bash on Windows, the first question is whether you need a handy shell for Git or an actual Linux environment. Git Bash is a lightweight way to use Bash and common Unix-style tools. WSL runs a Linux distribution, with its own packages, filesystem, and shell.

Windows Terminal can host either one, but it does not install Bash. Pick the environment based on the tools your work needs.

Git Bash: a quick shell for Git workflows

Git Bash comes with Git for Windows. Install Git for Windows from an official source, then open Git Bash from the Start menu. You get Bash and a set of Unix-style utilities alongside Git, without setting up a Linux distribution.

It’s a good fit if you want to run commands such as git, cd, and grep in a familiar shell, or follow instructions that use basic Bash syntax. It is not a complete Linux system: it doesn’t provide the same Linux user space or package-management environment as a distribution running under WSL.

Git Bash uses Windows files, presented through Unix-style paths. You can use it for projects stored on your Windows drive, but don’t assume that a Linux package or tool installed elsewhere will automatically be available in this shell.

WSL: Bash inside a Linux distribution

Choose WSL when your project needs Linux packages, Linux-specific tools, or behavior closer to a Linux development environment. On a supported, up-to-date Windows 11 system, open PowerShell or Command Prompt as an administrator and run:

wsl --install
Enter fullscreen mode Exit fullscreen mode

This installs WSL and a default Linux distribution. Restart if prompted, then launch the distribution from the Start menu. On its first launch, create a Linux username and password. Those credentials belong to the distribution and do not need to match your Windows account.

After setup, install Linux software inside the distribution using its package manager. Installing a Windows application does not automatically install its Linux counterpart in WSL, and tools installed in WSL are separate from tools in Git Bash.

The command above is the simple installation path for supported systems, not a universal fix for every Windows setup. If wsl --install is unavailable, check your Windows version and follow Microsoft’s current WSL installation instructions rather than applying older steps that may not match your system. You can list available distributions with:

wsl --list --online
Enter fullscreen mode Exit fullscreen mode

And inspect installed distributions with:

wsl --list --verbose
Enter fullscreen mode Exit fullscreen mode

Where your project files live matters

WSL starts in the Linux distribution’s filesystem. Windows drives are available under paths such as /mnt/c for the C: drive. For Linux development, keeping project files in the Linux filesystem is generally preferable; working across filesystem boundaries can affect performance and tool behavior.

Git Bash, by contrast, works with Windows files through its own path translation. If a command behaves differently between the two shells, check which shell you opened and where the project is stored before changing your setup.

For file synchronization between Windows and Linux, the available paths and tools depend on your environment; this guide to using rsync on Windows covers common options.

A quick check: which shell am I in?

In Git Bash or a WSL Bash session, try:

echo "$BASH_VERSION"
pwd
git --version
Enter fullscreen mode Exit fullscreen mode

BASH_VERSION should print a version string when the current shell is Bash. pwd shows your current directory, and git --version checks whether Git is available on that shell’s path.

If you use WSL, remember that Bash is not the only shell available on Windows. PowerShell is designed for Windows administration and has different syntax and command behavior. For example, connecting to a server over SSH from PowerShell lets you use a native Windows shell without switching to Bash.

Common mix-ups

A Linux command works in WSL but not Git Bash. The two environments have separate tools and paths. Install the tool in the environment where you intend to use it, and confirm which shell is running.

Windows Terminal opens PowerShell. Windows Terminal is a terminal host, not a Bash installation. Open Git Bash or your installed Linux distribution from Start, or select its profile from Terminal’s profile menu once available.

Git Bash isn’t in the Start menu. Check that Git for Windows installed successfully. You can search for git-bash.exe in its installation directory or rerun the official installer and review the selected components.

A script is written for a different shell. Bash and PowerShell have different syntax and conventions. A command that looks familiar in both may still behave differently; don’t assume a Bash script can run unchanged in PowerShell.

The short version

Use Git Bash for Git and common shell utilities with minimal setup. Use WSL when you need a Linux distribution, its package manager, or a closer match to a Linux development environment. They can coexist, but their installed tools and filesystems are not interchangeable. Choose the one that matches the software you need to run.

I originally published a more detailed version of this guide on the SSHFlow blog.

I'm also building SSHFlow — an SSH client where every server gets its own workspace for terminals, SFTP, code, and databases.

Top comments (0)