Back to Cheatsheets
Terminal & Git

Git Basics

Core Git commands for version control

Setup

4 items
CommandDescription
git init
Initialize new repository
git clone <url>
Clone repository
git config --global user.name "Name"
Set username
git config --global user.email "email"
Set email

Basic Workflow

5 items
CommandDescription
git status
Check repository status
git add <file>
Stage specific file
git add .
Stage all changes
git commit -m "message"
Commit staged changes
git commit -am "message"
Add and commit in one step

Remote Operations

5 items
CommandDescription
git remote add origin <url>
Add remote repository
git push origin <branch>
Push to remote
git push -u origin main
Push and set upstream
git pull
Fetch and merge from remote
git fetch
Download remote changes without merging

History & Inspection

5 items
CommandDescription
git log
View commit history
git log --oneline
Compact history view
git diff
Show unstaged changes
git diff --staged
Show staged changes
git show <commit>
Show commit details