Basics

"Git Bash: What It Is and How to Use It on Windows"

Updated: · Skillaria.Top

Git Bash is a terminal for Windows that ships with Git for Windows and gives you a familiar Unix environment: the bash shell, commands like ls, cd, cat, grep, ssh, and Git itself. It lets Git commands and documentation instructions work on Windows the same way they do on Linux and macOS.

What is Git Bash?

Git Bash is a Windows application that's installed along with Git for Windows and opens a terminal window running the bash shell. Inside it you get Git itself plus a set of standard Unix utilities: ls, cd, pwd, cat, grep, find, less, ssh, ssh-keygen, curl, and more.

Technically it's a port of the MSYS2 environment: the programs are compiled for Windows but behave like they do on Linux. The default terminal window is the MinTTY emulator. It isn't a virtual machine or a full Linux system — that's what WSL is for. Git Bash is lighter: it starts instantly and works directly with your Windows files.

People sometimes search for it as "git bush" — it's the same thing. Bash stands for Bourne Again SHell and has nothing to do with shrubs.

Why use Git Bash when you have cmd and PowerShell?

Git works perfectly well in PowerShell and the regular Command Prompt. But Git Bash has practical advantages, especially for beginners.

  • The same commands on every OS. Git docs, forum answers, GitHub guides, and courses write commands for bash. In Git Bash they work as-is: rm -rf build, cat ~/.ssh/id_ed25519.pub, export VAR=value.
  • SSH tools out of the box. ssh-keygen, ssh-agent, and ssh-add are already there — you can create a key for GitHub in a minute.
  • Git hints in the prompt. Git Bash shows the current branch right in the prompt, e.g. (main), and during a merge — (main|MERGING).
  • Tab completion. Tab completes Git commands, branch names, and file names.
  • A skill for the future. Servers, Docker containers, and CI run on Linux. Once you're used to bash in Git Bash, you'll feel right at home on a server.

Git Bash vs Git CMD vs PowerShell: what's the difference?

After installing Git for Windows, several entries show up in the Start menu, which can be confusing.

ToolWhat it isWhen to use it
Git BashA bash shell with Unix utilities and GitDay-to-day Git work, following instructions from the internet
Git CMDThe regular Windows Command Prompt (cmd.exe) with Git on the PATHIf you're used to cmd and only need git commands
Git GUIA simple Tcl/Tk graphical clientVisually assembling a commit; rarely used
PowerShell / cmdThe standard Windows terminalsGit works if you chose the PATH option "from the command line and also from 3rd-party software" during installation

Git CMD isn't a separate program — it's plain cmd with a preconfigured environment. Git commands are the same, but ls, cat, and grep don't work there: you use dir, type, and findstr instead. When people search for "cmd git", they usually mean how to run git from the standard Command Prompt. The answer: nothing special, just run git status as long as Git is on your PATH.

How to open Git Bash

From the Start menu

Type "Git Bash" and launch the app. The terminal opens in your user's home folder: /c/Users/YourName, which bash refers to as ~.

In a specific folder via the context menu

The most convenient way: in File Explorer, right-click an empty spot inside your project folder and choose "Open Git Bash here". In Windows 11 this option is tucked away under "Show more options" (or use Shift + right-click).

In the VS Code terminal

Open the terminal (Ctrl + `), click the arrow next to "+", and choose Git Bash. To make it the default, run the "Terminal: Select Default Profile" command and pick Git Bash.

In Windows Terminal

Git for Windows can add a Git Bash profile to Windows Terminal for you (an option in the installer). If the profile isn't there, create a new one with the command C:\Program Files\Git\bin\bash.exe -i -l.

Paths and files: the key difference from Windows

In Git Bash, paths are written Unix-style. The C: drive becomes /c, and backslashes become forward slashes.

WindowsGit Bash
C:\Users\Anna\projects/c/Users/Anna/projects
D:\work/d/work
%USERPROFILE%~ or $HOME

If a path contains spaces, wrap it in quotes: cd "/c/Users/Anna/My Projects". You can open the current folder in File Explorer with explorer ., and in VS Code with code ..

Basic Git Bash commands for beginners

Navigation and files

pwd                 # where am I
ls -la              # list files, including hidden ones (.git, .gitignore)
cd projects/site    # go into a folder
cd ..               # go up one level
mkdir new-app       # create a folder
touch index.html    # create an empty file
cat README.md       # print file contents
rm file.txt         # delete a file
rm -r old-folder    # delete a folder and its contents
clear               # clear the screen

Your first repository, right in Git Bash

$ mkdir my-first-repo && cd my-first-repo
$ git init
Initialized empty Git repository in C:/Users/Anna/my-first-repo/.git/
$ echo "Hello, Git" > hello.txt
$ git add hello.txt
$ git commit -m "Add hello.txt"
$ git log --oneline

After git init the prompt changes: the branch name appears in parentheses. It's a quick way to tell you're inside a repository.

Handy tricks

  • Tab — completes commands, branches, and files. Press it twice to see the options.
  • Up arrow — previous command; history — the full history; Ctrl + R — search your history.
  • Copy/paste — in MinTTY, selecting text with the mouse copies it right away; paste with Shift + Insert or a right-click. Ctrl + C in the terminal interrupts a command rather than copying.
  • q — quits the pager (git log and git diff open in less).
  • Esc, then :q! and Enter — exits Vim if it opened for a commit message.

Git CLI: why it's worth learning the command line

The Git CLI is Git's command-line interface — the git ... commands themselves. GUI clients are nice for browsing history, but they have limits: not every operation is available, and when something goes wrong, a button won't explain what's happening. The command line gives you full control and detailed messages.

Another argument: in an interview or on a new team, you'll be asked to show how you undo a commit or resolve a conflict, and everyone uses a different GUI. Commands are the same everywhere. A good strategy is to work in the CLI and use a GUI or your IDE's built-in tools for viewing diffs and history.

Customizing Git Bash

Aliases in ~/.bashrc

On startup, Git Bash reads ~/.bash_profile and ~/.bashrc. Add shortcuts there:

alias gs='git status'
alias gl='git log --oneline --graph --all'
alias ll='ls -la'

To apply the changes without restarting, run source ~/.bashrc. If you see a warning on startup that a .bashrc was found but no .bash_profile, Git Bash will create .bash_profile itself — that's normal.

Git's own aliases

You can also store aliases in Git itself, so they work in any terminal:

git config --global alias.st status
git config --global alias.lg "log --oneline --graph --all"

Now git st and git lg work in both Git Bash and PowerShell.

Appearance

Font, size, colors, and transparency are set by right-clicking the window title → Options. For non-Latin characters, make sure UTF-8 is selected as the character set in the Text section.

Common Git Bash problems

Garbled characters in git log

Setting the character set to UTF-8 in Options → Text and adding the line export LANG=en_US.UTF-8 to ~/.bashrc usually helps. For file names with non-ASCII characters in git status, run git config --global core.quotepath false — otherwise they show up as escaped sequences like \320\277.

Interactive programs hang

Some console programs (for example, the Python interpreter or node without arguments) behave oddly in MinTTY. Run them through winpty: winpty python, or use Git Bash inside Windows Terminal.

Paths turn into something weird

MSYS automatically converts arguments that look like Unix paths into Windows paths. Sometimes that gets in the way, e.g. when passing /app to docker run. The fix is to double the slash (//app) or set MSYS_NO_PATHCONV=1 for the command.

"Permission denied (publickey)" on push

Your SSH key hasn't been created or hasn't been added to GitHub. Create a key in Git Bash with ssh-keygen -t ed25519 -C "you@example.com", add the contents of ~/.ssh/id_ed25519.pub to your GitHub settings, and test it with ssh -T git@github.com.

Git Bash or WSL?

WSL is a real Linux inside Windows, with its own file system and packages. You need it if you develop for Linux: running Docker, compiling, using a server stack. Git Bash is simpler and lighter, and it's fully sufficient for working with Git. Just don't mix them: a repository cloned inside WSL is best handled by Git in WSL, and a repository on the C: drive by Git for Windows.

Summary

Git Bash is a terminal with bash and Unix utilities that comes with Git for Windows. It makes Windows compatible with Git documentation and tutorials, gives you SSH out of the box, and shows the current branch in the prompt. Git CMD is the same Git in the regular Command Prompt, without Unix commands. For learning and everyday work on Windows, go with Git Bash — it's the main terminal used in the hands-on sessions of the Git course.

FAQ

Is Git Bash free?

Yes, Git Bash is part of Git for Windows and is distributed free of charge under an open-source license.

Can I install Git Bash separately from Git?

No, Git Bash is installed only together with Git for Windows. If Git is already installed, Git Bash is in your Start menu.

Is there Git Bash for macOS and Linux?

There's no separate program, and you don't need one: the built-in terminal on macOS and Linux already runs bash or zsh with Unix utilities.

Where does Git Bash keep its home folder and settings?

The home folder is C:\Users\YourName, available in bash as ~. That's also where .bashrc, .bash_profile, .gitconfig, and the .ssh folder live.

Can I run .bat and .exe files in Git Bash?

Yes, Windows programs run by name or path, for example ./build.bat or notepad file.txt.

Learn this topic on video

This topic is covered in depth with practice in the course “Git from Scratch to Confident Developer”.

Go to course