Git Bash for Windows: what it is and how to use it

Install Git Bash on Windows, learn how its paths work, and use its built-in ssh, scp and ssh-keygen to manage a Linux server.

6–9 minutes
Hands typing on a laptop keyboard

Git Bash is a small Linux-style command line for Windows that comes free with Git for Windows. This guide is for Windows users who look after a website or server and want to install Git Bash, understand how it differs from a real Linux system, and use it to connect to and manage a server.

Git Bash is the Bash shell plus common Linux tools such as ssh, scp, ssh-keygen, grep and nano, bundled with Git for Windows. Install it from git-scm.com or with **winget install --id Git.Git -e --source winget, then open Git Bash from the Start menu. Your Windows drives appear as paths like /c/Users/exampleco**, and your home folder ~ is your normal Windows user folder.

What Git Bash is, and what it is not

Git is the version control tool most developers use to track changes to code. On Linux and macOS it runs in a terminal that already has the Bash shell (the program that reads the commands you type). Windows has no Bash of its own, so the Git for Windows project ships one, along with a set of familiar Linux commands, so that Git and its scripts behave the same way they do elsewhere.

That bundle is useful well beyond Git. It gives you a Linux-like command line on Windows in a few minutes, with the same ssh client you would use on a Mac to reach a server. See the SSH glossary entry if that term is new.

What Git Bash is not is a Linux system. The commands are Windows programs built to behave like their Linux versions. There is no apt, no systemctl and no way to install a real web serverWeb server The program that answers visitors’ browsers and sends them your website. Also used for the computer it runs on. More about Web server → inside it. If you want to practise running a server on your own PC, WSL is the better tool. If you just want to type commands at a remote server, Git Bash is lighter and quicker to set up.

ToolWhat you getGood for
Git BashBash and common Linux commands running as Windows programsGit, SSH, copying files, quick scripts
WSLA real Linux distribution such as Ubuntu inside WindowsLearning Linux, testing server software locally
PowerShellThe Windows shell, with the built-in OpenSSH clientWindows administration, simple SSH sessions

How to install Git Bash

1. Download Git for Windows

Go to the official download page at git-scm.com and choose the standard 64-bit installer. Alternatively, open PowerShell and run:

winget install --id Git.Git -e --source winget

winget is the package manager built into current versions of Windows 10 and 11. The -e flag asks for an exact match, so you get the official Git package and not something with a similar name.

2. Work through the installer

The installer asks a lot of questions. The defaults are sensible for almost everyone. The few worth reading:

  • Default editor: Git uses Vim unless you change it. If you have never used Vim, choose Nano, which shows its keyboard shortcuts at the bottom of the screen.
  • SSHSSH A secure way to type commands on a server from your own computer, as if you were sitting at it. More about SSH → executable: leave it on Use bundled OpenSSH. This is the ssh you will use from Git Bash.
  • Line ending conversion: the default, Checkout Windows-style, commit Unix-style line endings, is right for Git projects. It matters later if you copy scripts to a server (see Common problems).
  • Terminal emulator: the default is MinTTY, a resizable window with copy and paste support.
  • Windows Terminal profile: if offered, tick the option to add a Git Bash profile so it appears in Windows Terminal’s tab menu.

3. Open it and check it works

Open the Start menu and choose Git Bash. You can also right-click inside any folder in File Explorer and choose Open Git Bash here (on Windows 11 it sits under Show more options). Then run:

git --version
ssh -V
pwd

Success looks like a Git version number, an OpenSSH version line and a path such as /c/Users/exampleco.

How paths and files work in Git Bash

This is the part that confuses people most. Git Bash uses Linux-style paths, with forward slashes, and shows each Windows drive as a folder at the top level.

Windows pathGit Bash path
C:\Users\exampleco/c/Users/exampleco or ~
C:\Users\exampleco\Documents\site~/Documents/site
D:\backups/d/backups
C:\Users\exampleco\.ssh~/.ssh

Some everyday commands:

cd ~/Documents
ls -la
mkdir site-backup
explorer .

explorer . opens the current folder in File Explorer, which is handy when you want to see the files you just downloaded. Windows commands such as ipconfig and nslookup also run from Git Bash, because it can see the normal Windows program path.

Because ~/.ssh is the same folder that the Windows built-in OpenSSH uses, keys you create in Git Bash also work from PowerShell, and the other way round.

To paste into the default MinTTY window, use Shift+Insert or right-click and choose Paste. Selecting text with the mouse copies it. Ctrl+C does not copy: it stops the running command, as it does on Linux.

Using Git Bash to work on a server

Git Bash shines as your Windows command line for server work. Everything here uses 203.0.113.10 as the server and exampleco as the user name; replace them with your own.

Connect with SSH

ssh exampleco@203.0.113.10

If your host uses a different portPort A numbered door on a server. Each service listens behind its own door: web pages on 443, email on others, remote login on 22. More about Port →, add -p:

ssh -p 2222 exampleco@203.0.113.10

The first time, you are asked to confirm the server’s fingerprint. Type yes. Type exit to leave the server and return to Git Bash.

Create an SSH key

ssh-keygen -t ed25519 -C "exampleco-laptop"

Press Enter to accept the default location (~/.ssh/id_ed25519) and set a passphrase. This creates a private key, which stays on your PC, and a public key ending in .pub, which goes on the server.

Copy the public key to the server

This command works in Git Bash and on any Linux or macOS machine. It adds your public key to the server’s list of allowed keys and sets the permissions SSH expects:

cat ~/.ssh/id_ed25519.pub | ssh exampleco@203.0.113.10 "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys"

You type your password one last time. After that, ssh exampleco@203.0.113.10 should log you in with the key.

Avoid typing the passphrase every time

Start the SSH agent, a small program that holds your unlocked key in memory, and add your key to it:

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519

The agent lasts until you close the Git Bash window.

Copy files to and from the server

scp copies files over SSH. Upload a file to the server’s home folder:

scp ~/Documents/site/index.html exampleco@203.0.113.10:~/

Download a whole folder to your PC:

scp -r exampleco@203.0.113.10:/var/www/example.com ~/site-backup

Git Bash does not include rsync, which many server guides use for backups because it only copies files that have changed. If you need it, run it from WSL or directly on the server. Our guide to backing up a Linux server shows how.

Git Bash commands run on your PC. Once you have run ssh and see the server’s prompt, the commands you type run on the server. Check which one you are in before running anything that deletes files.

Common problems

SymptomCauseFix
ssh: connect to host 203.0.113.10 port 22: Connection timed outWrong address, wrong port or a firewall blocking SSHCheck the address and port in your hosting panel and try ssh -p with the right port
Permission denied (publickey)The server only accepts keys and yours is not on it, or you used the wrong user nameConfirm the user name, then add your public key through your host’s panel or console
A script copied to the server fails with /bin/bash^M: bad interpreterThe file has Windows line endingsOn the server, run sed -i 's/\r$//' script.sh, then set your editor to save with Unix (LF) line endings
Ctrl+V does nothingMinTTY uses different paste keysUse Shift+Insert or right-click and choose Paste
cd C:\Users failsBackslashes are escape characters in BashUse /c/Users or wrap the Windows path in quotes
apt: command not foundGit Bash is not a Linux systemRun the command on your server over SSH, or install WSL for a local Linux

Official documentation

Get the next guide

One email when there is something worth reading: new guides, errors going around, and hosting changes that affect your site.

No tracking pixels, and one click to leave.

Something out of date? Software changes. If a step no longer works, tell us and we will check it and update the page.