Cheatsheet

Chapter Command Description
cli pwd Displays the path of the current working directory
cli cd <PATH> Changes the current working directory to <PATH>
cli cd ~ Changes the current working directory to the user’s home directory
cli cd .. Moves up one folder
cli cd ../.. Moves up two folders
cli clear Clears the contents of your command line window
cli ls Lists files and folders in the current working directory
cli ls <PATH> Lists files and folders in <PATH>
cli ls -a Lists all files (including hidden files) in the current working directory
cli ls -alh Lists all files in a long format that is easy to read for humans
cli [Command] --help Displays all possible flags for a specific command (on Windows)
cli man [Command] Displays all possible flags for a specific command (on macOS)
cli mkdir <FOLDER> Creates a new folder called <FOLDER>
cli mkdir <FOLDER1> <FOLDER2> Creates two separate folders called <FOLDER1> and <FOLDER2>
cli touch <FILE> Creates a new empty file called <FILE>
cli open <FILE> Opens the file called <FILE> (on macOS)
cli start <FILE> Opens the file called <FILE> (on Windows)
cli echo "example text" >> file.txt Writes “example text” into file.txt
cli cat <FILE> Displays the content of <FILE>
cli mv FILE.txt <FOLDER> Move FILE.txt into <FOLDER>
cli mv <FOLDER_OLD> <FOLDER_NEW> Renames <FOLDER_OLD> to <FOLDER_NEW>
cli ls -alh *.csv Uses a wildcard to list all .csv files in the current working directory
cli rm -r <FOLDER> Removes the folder <FOLDER>
cli history Display the command history of the current terminal session
cli history > history.txt Saves the entire command history to a file named history.txt (overwrites existing content in history.txt)
cli history >> history.txt Adds the entire command history to the end of the file named history.txt
cli tree Displays a graphical representation of the directory structure
cli wget <URL> Downloads a file from the specified to the current directory
config git config Get an overview of Git config commands
config git config --global "user.name" Sets Git username
config git config --global "user.email" Sets Git email address
config git config --global core.editor "editorname" Sets Git text editor
config git config --global init.defaultBranch main Sets default branch name to main
config git config --list Views set Git configurations
basic git init Initializes a folder as a Git repository
basic git status Shows Git tracking status of files in the repository
basic git add Adds file(s) to the staging area
basic git commit Commits staged files
basic git commit -m "commit message" Commits staged files with a commit message
essentials git log Views past commits
essentials git diff Views made changes compared to the last commit
essentials git mv Renames or moves files and automatically stages the changes
remote_intro git remote Manages remote repositories
remote_intro git clone Creates a local copy of a repository
remote_intro git pull Fetches and merges the latest changes from a remote repository into the current branch
remote_intro git fetch Updates remote tracking branches
remote_intro git push Uploads local commits to a remote repository
github_advanced git blame Shows the authorship and commit information of each line in a file
branches git branch Lists / creates and deletes branches
branches git branch feature Creates the feature branch
branches git branch -d feature Deletes the feature branch
branches git switch Switches between branches
branches git switch feature Switches to the feature branch
branches git checkout Switches between branches
branches git checkout -b feature Creates and switches to the feature branch
branches git merge Merges branches
branches git merge feature Merges the feature branch into the current branch
branches git merge --abort Aborts a merge
branches git merge --squash Squaches commits on branch into a single commit and merge
branches git stash Stashes changes for later use
branches git stash -m "stashing message" Stashes changes and includes a message
branches git stash list Shows stored stashes
branches git stash apply Applies the latest stash
branches git stash apply stash@{n} Applies a specific stash
branches git stash pop Applies the latest stash and removes it from stash list
branches git stash pop stash@{n} Applies a specific stash and removes it from stash list
branches git cherry-pick <commithash> Applies changes from <commithash>
branches git rebase Different way of integrating changes from two branches
Tags and Releases git tag Lists all tags
Tags and Releases git tag v1.0 Creates a tag on the basis of your current commit named v1.0
Tags and Releases git tag v1.1 <commit-hash> Creates a tag on the basis of a specific commit hash named v1.1
Tags and Releases git tag -a v1.0 -m "Release version 1.0" Creates an annotated tag on the basis of your current commit hash named v1.0 with the tagging message Release version 1.0
Tags and Releases git push origin <tag-name> Pushes a specific tag to remote
Tags and Releases git push origin --tags Pushes all created tags to remote
Tags and Releases git fetch --tags Fetches all created tags from remote
Tags and Releases git pull --tags Pulls all created tags from remote
rewriting_history git restore <FILE> Reverts <FILE> back to the state of your last commit
rewriting_history git restore . Reverts all files in your repository back to the state of your last commit
rewriting_history git restore --staged <FILE> Removes <FILE> from your staging area
rewriting_history git restore --staged . Removes all files in your repository from your staging area
rewriting_history git rm <FILE> Deletes <FILE> from your repository
rewriting_history git rm --cached <FILE> Removes <FILE> from your repository but keeps <FILE> on your system
rewriting_history git revert <commithash> Creates a new commit which reverts your repository back to <commithash>
rewriting_history git reflog Logs recent branch changes
rewriting_history git reset <commithash> Resets the branch to a specified commit, keeping changes in the working directory
rewriting_history git reset --hard <commithash> Resets the branch to a specified commit
rewriting_history git clean Deletes untracked files from your directory
rewriting_history git filter-repo --invert-paths --path < PATH-TO-FILE-YOU-WANT-TO-REMOVE > Remove specified file from your repository history
rewriting_history brew install git-filter-repo Installs git filter-repo using brew