> For the complete documentation index, see [llms.txt](https://kmanu225.gitbook.io/cs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kmanu225.gitbook.io/cs/software-engineering/unix-linux-on-windows-choosing-the-right-environment/git-bash-a-lightweight-unix-like-shell-on-windows.md).

# Git Bash: A Lightweight Unix-like Shell on Windows

If [PowerShell](/cs/software-engineering/unix-linux-on-windows-choosing-the-right-environment/powershell-do-you-actually-need-linux.md) is not Unix-like enough for your workflow, but you do not need a full Linux environment, **Git Bash** is often the simplest next step.

Git Bash is installed with **Git for Windows** and provides Bash together with a useful set of Unix-style command-line tools.

It is lightweight, easy to install, and often sufficient for developers who mainly want familiar shell commands.

## What do you get?

After installing Git for Windows, you can open a Git Bash terminal and use commands such as:

```bash
ls -la
cd project
pwd
rm -rf build
grep "ERROR" application.log
find . -name "*.cpp"
ssh server
```

You also get Git itself:

```bash
git clone https://example.com/project.git
git status
git commit
git push
```

Unlike PowerShell aliases, commands such as `ls`, `rm`, and `grep` behave much more like their Unix counterparts.

This can be convenient when following documentation written for Linux or macOS.

## A good fit for Git-oriented workflows

Git Bash is especially useful when your workflow mainly involves:

* Git;
* SSH;
* Bash scripts;
* `grep`, `sed`, `awk`, `find`, and similar utilities;
* simple build or automation scripts;
* remote Linux servers.

For example:

```bash
git clone my-project
cd my-project

./build.sh

ssh deploy-server
```

For this kind of workflow, installing a complete Linux environment may be unnecessary.

## How to get it

Git Bash is included with **Git for Windows**.

Install Git for Windows using its standard installer or your preferred Windows package manager, then launch **Git Bash** from the Start menu or Windows Terminal.

There is normally nothing else to configure for basic usage.

## It looks like Linux, but it is not Linux

This is the important limitation.

Git Bash gives you Bash and many Unix utilities, but it does **not** provide:

* a Linux kernel;
* Linux system libraries;
* `apt` or other Linux package managers;
* Linux system calls;
* the ability to run normal Linux binaries.

For example, a Linux executable such as:

```
mytool
```

compiled as an ELF binary cannot simply be executed inside Git Bash.

The programs provided by Git Bash are Windows programs adapted to provide a Unix-like command-line environment.

## Bash scripts: often, but not always

Simple Bash scripts often work very well:

```bash
#!/usr/bin/env bash

mkdir -p build
cd build
cmake ..
cmake --build .
```

But scripts that depend on Linux-specific features may fail.

For example, a script may assume the existence of:

```
/proc
/dev
systemd
apt
Linux-specific filesystem behavior
Linux-only executables
```

At that point, Git Bash is no longer enough.

## Windows paths can also be surprising

Git Bash presents Windows paths in a Unix-like form.

For example:

```
C:\Users\john\project
```

becomes roughly:

```
/c/Users/john/project
```

This makes Bash commands convenient, but it can occasionally cause problems when scripts mix Windows and Unix path conventions.

For simple shell usage this is rarely an issue, but build systems and scripts that pass paths between Windows applications and Bash utilities sometimes require extra care.

## Should you use Git Bash?

| Need                                | Git Bash             |
| ----------------------------------- | -------------------- |
| Git and SSH                         | **Excellent choice** |
| Bash terminal on Windows            | **Yes**              |
| `grep`, `sed`, `awk`, `find`, `tar` | **Yes**              |
| Simple Bash scripts                 | **Usually**          |
| GNU-style command options           | **Mostly**           |
| Native Windows applications         | **Yes**              |
| Linux package management            | **No**               |
| Linux binaries                      | **No**               |
| Complete Linux environment          | **No**               |

Git Bash is therefore a good choice when your requirement is essentially:

> **"I want a familiar Unix command line on Windows."**

It adds relatively little complexity and is often already installed because developers need Git anyway.

But if your objective is not just to *use* Unix tools, but to **compile native Windows software using the** [**GNU toolchain**](/cs/software-engineering/unix-linux-on-windows-choosing-the-right-environment/mingw-w64-gnu-tools-on-windows.md), we need to go one step further.
