Cheat Sheet Library

Git Bash Cheat Sheet

A Bash shell for Windows, installed with Git for Windows. You get Linux commands (ls, grep, ssh…) on your Windows files. For Git commands, see the Git cheat sheet.

  • 43 entries
  • 8 sections
  • Updated
  • Click a command to see all its options

43 entries

On this page

Windows ↔ Git Bash Paths #

WindowsGit Bash
C:\Users\milan/c/Users/milan or ~
D:\Projects/d/Projects
\ (backslash)/ (forward slash)
%USERPROFILE%$HOME

Everyday Commands #

CommandAction
Show the current folder
List files and folders ( = all files, with details)
/ Home folder / previous folder
Create nested folders
Create an empty file
Copy a folder
Move / rename
Delete a folder (no Recycle Bin!)
/ View a file
/ First lines / follow a log
Search text recursively
Find files
Count lines
Where a program is located
or Ctrl + LClear the screen

Windows Integration #

CommandAction
or Open the current folder in Explorer
Open a URL in the browser
Open a file in Notepad
Open the folder in VS Code
Copy file content to the Windows clipboard
Run interactive Windows programs correctly (python, node REPL)
Run a cmd command

Copy & Paste (mintty window) #

KeyAction
Select textCopies automatically
Shift + InsertPaste
Ctrl + InsertCopy
Right-clickContext menu (or paste, depending on options)
Alt + EnterFull screen

Keyboard (Bash) #

KeyAction
TabAutocomplete
Ctrl + RSearch command history
Ctrl + A / Ctrl + EStart / end of line
Ctrl + U / Ctrl + KDelete before / after the cursor
Ctrl + WDelete the previous word
Ctrl + CStop the command
!!Repeat the last command

SSH Keys (for GitHub etc.) #

ssh-keygen -t ed25519 -C "you@example.com"   # create a key
eval "$(ssh-agent -s)"                        # start the agent
ssh-add ~/.ssh/id_ed25519                     # load the key
cat ~/.ssh/id_ed25519.pub | clip              # copy the public key → paste it on GitHub
ssh -T git@github.com                         # test

Config Files #

FileUse
~/.bashrcAliases and functions (loaded for every shell)
~/.bash_profileLogin shell; usually just
~/.gitconfigGit settings
~/.minttyrcWindow font and colors
# ~/.bashrc examples
alias ll='ls -la'
alias gs='git status'
alias proj='cd /c/Repositories'

Reload with source ~/.bashrc.

Tips #

  • If a path like /c/... gets mangled when passed to a Windows program, prefix the command with MSYS_NO_PATHCONV=1.
  • Line endings: git config --global core.autocrlf true on Windows prevents CRLF/LF diffs.
  • Use Git Bash inside Windows Terminal or the VS Code terminal for tabs and better fonts.