Alex Garbiak
← Lib

Git Bash Shell Command Reference

Updated git-bashwindowsshellclicheatsheet

A general-purpose baseline for now — the plan is to trim this down to the commands and flags I actually use day to day, and drop the rest.

CommandDescription
pwdPrint the current working directory.
cd <dir>Change directory.
cd ..Move up one directory.
cd -Switch back to the previous directory.
cd ~Go to the home directory ($HOME).
lsList directory contents.
ls -laList all entries (including hidden), long format.
ls -lhLong format with human-readable file sizes.

Files & directories

cp

Copy files or directories.

FlagDescription
-rCopy directories recursively.
-vVerbose — print each file as it’s copied.
-iPrompt before overwriting an existing file.

mv

Move or rename a file or directory.

FlagDescription
-iPrompt before overwriting a destination.
-vVerbose — print each move.

rm

Remove files or directories.

FlagDescription
-rRemove directories and their contents recursively.
-fForce — ignore missing files, never prompt.
-iPrompt before every removal.

mkdir / rmdir

CommandDescription
mkdir <dir>Create a directory.
mkdir -p <a/b/c>Create nested directories, creating parents as needed.
rmdir <dir>Remove an empty directory.

touch

Create an empty file, or update its modified timestamp if it already exists.

Reading & searching text

CommandDescription
cat <file>Print a file’s contents.
cat -n <file>Print with line numbers.
less <file>Page through a file’s contents.
head <file>Show the first 10 lines.
head -n <count> <file>Show the first <count> lines.
tail <file>Show the last 10 lines.
tail -f <file>Follow a file as it grows (e.g. a log).
wc -l <file>Count lines in a file.

grep

Search text using patterns.

FlagDescription
-iCase-insensitive search.
-rSearch recursively through a directory.
-nShow line numbers with matches.
-vInvert match — show non-matching lines.
-EUse extended regular expressions.

find

Locate files and directories.

ExampleDescription
find . -name "*.md"Find files by name pattern under the current directory.
find . -type dFind directories only.
find . -mtime -1Find files modified in the last day.

Permissions & ownership

CommandDescription
chmod +x <file>Make a file executable.
chmod 644 <file>Set explicit permission bits (owner rw, group/other r).
ls -lShow permission bits alongside file listings.

Process & environment

CommandDescription
psList running processes for the current shell session.
kill <pid>Terminate a process by PID.
which <cmd>Show the path to the executable that would run for <cmd>.
alias ll='ls -la'Define a shortcut command for the current session.
export VAR=valueSet an environment variable for the current shell and its children.
echo $VARPrint the value of an environment variable.
historyShow recently run commands.
clearClear the terminal screen.

Windows-specific notes

  • Git Bash provides a MinGW/MSYS POSIX layer over Windows — most core utilities above (ls, grep, find, etc.) are real GNU coreutils, not emulations.
  • Windows paths and POSIX paths are both understood: cd /c/Users/<name> is equivalent to C:\Users\<name>.
  • Use winpty <command> to fix broken interactive input/output for some native Windows console programs run from Git Bash.
  • Line endings: configure git config --global core.autocrlf true so Git converts LF to CRLF on checkout and back on commit for cross-platform repos.
  • There’s no native sudo; commands requiring elevation are run from an elevated Windows terminal instead.