🐙 GitHub: From Zero to Hero
🐍 PyCharm Guide
🎓 Open Source · Free for Everyone

Git & GitHub
From Zero to Pro

Master version control — the one skill every developer needs, regardless of language or field.

8
Modules
~4h
Total Time
1
Real Project
7
ER Cases
💾

Never Lose Work Again

Every commit is a save point. Break something? Jump back to any moment in your project's history in seconds.

🌐

Your GitHub = Your Resume

Recruiters look at GitHub profiles. Active, well-structured repos demonstrate real-world skills better than a bullet point on paper.

🤝

Work Like a Pro

Every tech company — from startups to FAANG — uses Git. Learning it now means zero friction when you join a team.

BEGINNER INTERMEDIATE ADVANCED M0 Setup M1 Commits M2 GitHub M3 Branching M4 PRs M5 Fixes M6 Actions M7 Advanced
🧭
Module 0

Core Concepts & Setup

C1 C2 C3
  • Git vs GitHub — what's the difference
  • Install and configure Git
  • Key vocabulary explained simply
📦
Module 1

Your First Commits

Work add Stage commit Repo
  • git init, add, commit explained
  • The staging area — why it exists
  • Reading git log and git status
☁️
Module 2

Connect to GitHub

💻 push pull ☁️
  • Push your repo to GitHub
  • git push, pull, clone, fetch
  • Authentication with PAT & SSH
🌿
Module 3

Branching

  • Create and switch branches
  • Merge branches together
  • Resolve merge conflicts step-by-step
🤝
Module 4

Collaboration & PRs

Fork PR
  • Fork vs clone explained
  • Open and review Pull Requests
  • Issues, code review best practices
🔧
Module 5

When Things Go Wrong

!
  • Undo changes safely (restore, reset, revert)
  • .gitignore — never commit secrets
  • Fix: push rejected, detached HEAD, and more
Module 6

GitHub Actions

Code Test ✓ CI 🚀
  • What CI/CD means and why it matters
  • Write your first workflow YAML
  • Auto-run tests on every push
🚀
Module 7

Advanced Git

merge rebase
  • git stash, rebase, cherry-pick
  • Tags, releases, aliases
  • git bisect — find the commit that broke things
📋
Reference

Cheat Sheet

  • Every command, organized by category
  • Copy-to-clipboard on each command
  • Quick reference during any project
🏥

Git Emergency Room

7 real disasters students cause — with step-by-step recovery. From "I committed my password" to "I force-pushed to main." No judgment, just fixes.

🧭
Beginner ⏱ 20 min

Module 0 · Core Concepts & Setup

The Problem Git Solves

Before Git vs After Git — you've done the left side before
😰 Without Git
📁 my-essay/
├── essay_v1.docx
├── essay_v2_FINAL.docx
├── essay_v2_FINAL_real.docx
├── essay_SEND_THIS_ONE.docx
├── essay_NO_THIS_ONE.docx
└── essay_OK_THIS_IS_IT.docx
Which file is the latest? Nobody knows.
✅ With Git
● a3f9c12 Fix conclusion paragraph 2h ago
● 2d3e4f8 Add citations section yesterday
● 1a2b3c4 Write introduction Mon
● 8c7d6e5 Outline structure last week
 
Jump to any version instantly.
One folder. Clean history. No guessing.

What is Git?

Analogy
Think of Git as save points in a video game. Every time you commit, you take a snapshot of your code. If something breaks, you can jump back to any save point instantly. Git stores all these snapshots locally on your machine — no internet needed.

Git vs GitHub — not the same thing

Your Computer git repository (local — offline) GitHub remote repository (cloud — online) git push git pull / clone
GitGitHub
Software on your computerA website (github.com)
Tracks history of your filesHosts your repos online
Works 100% offlineEnables collaboration & sharing
Free, open-source toolFree plan + paid tiers

Key Vocabulary

TermPlain English
repository (repo)A folder Git is tracking — contains your project + all its history
commitA saved snapshot of your project at one moment in time
branchA parallel version of your code — like a separate timeline
mergeCombining two branches back together
remoteA copy of your repo stored somewhere else (usually GitHub)
cloneDownload a remote repo to your computer for the first time
forkCopy someone else's repo into your own GitHub account
pull request (PR)A proposal to merge your changes into someone else's branch
HEADA pointer to the commit you're currently on

Install & Configure Git

1
Install Git
macOS (Terminal)
git --version   # if not found, macOS will prompt you to install
# OR install via Homebrew:
brew install git
Windows
# Download and install from: https://git-scm.com/downloads
# Opens "Git Bash" — use that as your terminal
Linux (Ubuntu/Debian)
sudo apt update && sudo apt install git
2
Tell Git who you are — do this once
git config --global user.name  "Your Name"
git config --global user.email "you@example.com"
git config --global init.defaultBranch main   # modern default
ℹ️
This info is attached to every commit you make. Use the same email as your GitHub account.
3
Verify everything is set
git config --list
Terminal
$ git config --list
user.name=Your Name
user.email=you@example.com
init.defaultbranch=main
🎯 Project Task Module 0 Setup
  • Install Git and open a terminal
  • Run git config --global user.name "Your Name"
  • Run git config --global user.email "you@example.com"
  • Create a free account at github.com
📦
Beginner⏱ 30 min

Module 1 · Your First Commits

The Three Areas of Git

The Staging Machine — how files travel to become commits
📝
Working Directory
your edited files
git sees them as "modified"
git add
📋
Staging Area
files you chose
ready to be saved
git commit
🗄️
Repository
permanent snapshot
in Git history forever

Staging lets you choose exactly which changes go into a commit — even from the same file.

Mental Model — The Post Office
Working directory — your desk, files you're editing right now.
Staging area — a box on the desk, files you've put in to mail.
Repository — the post office archive, files that have been sent & recorded forever.
Working Dir your edited files Staging Area files ready to commit Repository permanent history git add git commit

Core Commands

1
Create a new project folder and initialize Git
mkdir my-tech-wiki
cd my-tech-wiki
git init
Terminal
$ git init
Initialized empty Git repository in /Users/you/my-tech-wiki/.git/

A hidden .git/ folder is created — this is where Git stores all history. Never delete it.

2
Create your first file
README.md
# My Tech Wiki

A personal wiki where I document things I learn about Git and GitHub.

## Topics
- Git basics
3
Check status — what has Git noticed?
git status
Terminal
$ git status
On branch main
Untracked files:
(use "git add <file>..." to include in what will be committed)
README.md
nothing added to commit but untracked files present

Red means Git sees the file but is not tracking it yet.

4
Stage the file (add it to the box)
git add README.md       # stage one file
# OR stage everything in the folder:
git add .
⚠️
git add . stages everything — be careful not to accidentally stage passwords or secrets. We'll set up .gitignore in Module 5.
5
Commit — create the save point
git commit -m "Initial commit: add README"
Terminal
$ git commit -m "Initial commit: add README"
[main (root-commit) a3f9c12] Initial commit: add README
1 file changed, 6 insertions(+)
create mode 100644 README.md
6
View your history
git log --oneline   # compact view — one line per commit
Terminal
$ git log --oneline
a3f9c12 (HEAD -> main) Initial commit: add README
💡
Write good commit messages. Use a verb in present tense: "Add login page", "Fix typo in README", "Remove unused imports". Future-you will thank past-you.
⚠️ Common Issues — Module 1

"Nothing to commit, working tree clean" — Git sees no changes since the last commit. Edit a file first, then add and commit.

"fatal: not a git repository" — You're in the wrong folder. Run git init first, or cd into your project directory.

I forgot to include a file in my last commit — Stage the file and run:

git add forgotten-file.txt
git commit --amend --no-edit   # adds to the LAST commit
⚠️
Only amend commits that haven't been pushed to GitHub yet.

"Please tell me who you are" error — Run git config from Module 0 to set your name and email.

🎯 Project Task Module 1 — Create my-tech-wiki
  • Create a folder called my-tech-wiki and run git init inside it
  • Create a README.md with your name and a one-line description
  • Stage and commit it: git add README.md then git commit -m "Initial commit"
  • Create a file git-basics.md, add 3 things you learned, commit it
  • Run git log --oneline and see your two commits
☁️
Beginner⏱ 30 min

Module 2 · Connect to GitHub

Local ↔ Remote — what lives where
💻
Your Computer
local repo
git push
git pull
☁️
GitHub
remote repo

git clone = first-time download  |  git fetch = download without merging yet

Push your local repo to GitHub

1
Create a new repo on GitHub

Go to github.com → "+" → New repository.
Name it my-tech-wiki. Keep it public. Do not add a README (you already have one).

🚫
Do NOT initialize with README, .gitignore, or license when pushing an existing local repo — it will cause a conflict on your first push.
2
Link your local repo to GitHub and push
# Replace YOUR-USERNAME with your GitHub username
git remote add origin https://github.com/YOUR-USERNAME/my-tech-wiki.git
git push -u origin main
Terminal
$ git push -u origin main
Enumerating objects: 4, done.
Writing objects: 100% (4/4), 432 bytes | 432 KiB/s, done.
Branch 'main' set up to track remote branch 'main' from 'origin'.

The -u flag links your local branch to the remote. After this, you can just type git push.

3
Authenticate (first-time push only)

GitHub no longer accepts your account password. Use a Personal Access Token (PAT):

  1. Go to GitHub → Settings → Developer Settings → Personal Access Tokens → Tokens (classic)
  2. Generate a new token — check the repo scope
  3. Copy the token and paste it as your password when Git prompts you
💡
Recommended alternative: Use SSH keys to never type a password again. Follow: ssh-keygen -t ed25519 -C "you@example.com" then add the public key to GitHub Settings → SSH Keys.

Everyday Remote Workflow

# Before you start working — get latest changes from GitHub
git pull

# Do your work, then:
git add .
git commit -m "Describe what you did"
git push

Cloning — Get Someone Else's Repo

# Download a repo to your machine (one-time)
git clone https://github.com/USERNAME/REPO-NAME.git

Cloning already sets up the remote automatically. You can immediately git pull and git push.

Key Remote Commands

CommandWhat it does
git remote -vShow where "origin" points (the GitHub URL)
git pushUpload your local commits to GitHub
git pullDownload + merge GitHub changes into your local branch
git fetchDownload changes but don't merge yet (inspect first)
git clone <url>Copy a repo from GitHub to your computer
⚠️ Common Issues — Module 2

"rejected: non-fast-forward" — GitHub has commits your local repo doesn't have. Run git pull first, then push again.

"Authentication failed" — Your password won't work. Create a Personal Access Token (see Step 3 above) or set up SSH.

"remote origin already exists" — Remove it and re-add: git remote remove origin then git remote add origin <url>

Wrong URL — Fix it: git remote set-url origin https://github.com/YOU/REPO.git

🎯 Project Task Module 2 — Push to GitHub
  • Create a new repo on GitHub called my-tech-wiki
  • Run git remote add origin with your repo URL and push
  • Refresh github.com — you should see your files live
  • Edit README.md to add a link to git-basics.md, commit, and push
🌿
Intermediate⏱ 45 min

Module 3 · Branching

Why branch?

Analogy
A branch is a parallel universe for your code. You can experiment, break things, and build features in a branch without touching the stable main branch. When you're happy with the result, you merge the universes back together.
C1 C2 C5 C6 C3 C4 main feature/add-page merge commit

Branch Commands

ℹ️
Naming convention: Use feature/, fix/, or docs/ prefixes. Keep names short and hyphen-separated: feature/login-page, fix/typo-readme.

Merging — Bringing It All Together

Merge Conflicts — Don't Panic

What is a merge conflict?
Git can't automatically combine two edits to the same lines in the same file. It pauses and asks you to decide what the final version should be.

When a conflict happens, Git marks the file like this:

<<<<<<< HEAD
## Git is a version control system
=======
↑ YOUR version (current branch)    ↓ THEIR version (incoming branch)
=======
## Git tracks changes to your files
>>>>>>> feature/add-github-page
1
Open the conflicted file in your editor

VS Code shows conflict markers with buttons: "Accept Current", "Accept Incoming", or "Accept Both".

2
Edit the file to what you WANT it to say — delete all conflict markers
# The final version should look clean — no <<<, ===, or >>> lines
## Git tracks changes to your files over time
3
Mark the conflict as resolved and finish the merge
A merge conflict is not a failure — it's Git saying "I need a human to make a decision here." Stay calm, read the markers, and pick the right content.
⚠️ Common Issues — Module 3

"Detached HEAD" state — This means you're on a specific commit, not a branch. Anything you commit here could be lost. Fix it:

"You have unmerged paths" — You started a merge but didn't finish resolving conflicts. Fix all files with conflict markers, then git add and git commit.

I accidentally committed to main — Move the commit to a new branch:

⚠️
Only use reset --hard if you haven't pushed to GitHub yet.
🎯 Project Task Module 3 — Branch & Merge
  • Create a branch: git switch -c feature/github-page
  • Create github.md with notes on GitHub (remotes, push, pull)
  • Commit it on the feature branch
  • Switch back to main: git switch main
  • Merge: git merge feature/github-page
  • Push main to GitHub
🤝
Intermediate⏱ 40 min

Module 4 · Collaboration & Pull Requests

Fork vs Clone

ForkClone
WhatCopy a repo to YOUR GitHub accountDownload a repo to your computer
WhenContributing to someone else's public repoWorking on any repo you have access to
WhereOn GitHub (github.com)In your terminal
ResultA new repo owned by you on GitHubA local folder with the full history
Typical Open-Source Contribution Flow
Fork the repo → clone your fork → create a branch → make changes → push → open a Pull Request → get reviewed → merged.
PR Lifecycle — the full collaboration loop
🍴Fork
⬇️Clone
🌿Branch
✏️Commit
📤Push
🔀Open PR
👁️Review
Merge
⟳ If reviewer requests changes → go back to Commit, push again — the PR updates automatically

Pull Requests (PRs)

A Pull Request is a conversation about a proposed change. It lets teammates review your code before it's merged into main.

1
Push your feature branch to GitHub
git switch -c feature/my-change
# ... make changes, commit them ...
git push -u origin feature/my-change
2
Open a Pull Request on GitHub

After pushing, GitHub shows a banner: "Compare & pull request". Click it.
Fill in a clear title and description explaining what you changed and why.

3
Address review feedback

If a reviewer requests changes, just commit more to the same branch — the PR updates automatically.

4
After merge — clean up

Issues — Track Work

GitHub Issues are like a to-do list for your project. Great for bug reports, feature requests, and questions.

💡
Close an issue automatically from a commit or PR description: write Fixes #42 or Closes #42. When the PR merges, issue #42 closes automatically.

Code Review Tips

⚠️ Common Issues — Module 4

"This branch is X commits behind main" — Your fork is out of date. Update it:

PR has conflicts — Pull the target branch into your feature branch to resolve:

I pushed to the wrong branch — Move the commit:

🎯 Project Task Module 4 — Open a Pull Request
  • Create branch feature/branching-notes and add branching.md
  • Push the branch to GitHub
  • Open a Pull Request on GitHub with a description
  • Merge the PR on GitHub, then run git pull locally
  • Fork a classmate's repo and open a PR with an improvement
🔧
Intermediate⏱ 40 min

Module 5 · When Things Go Wrong

Undo Decision Tree — pick the right command before you panic
😱 Made a mistake? Already pushed to GitHub? YES NO git revert HEAD Creates a NEW commit that undoes the last one. Safe ✅ Keep the changes? YES git reset --soft HEAD~1 Removes commit, keeps files staged and ready to re-commit NO git reset --hard HEAD~1 ⚠ Deletes changes Not staged yet? git restore <file> discards unsaved edits

Undoing Changes — Choose the Right Tool

SituationCommandSafe to push?
Discard changes to a file (not staged)git restore <file>✅ yes
Unstage a file (keep changes)git restore --staged <file>✅ yes
Undo last commit (keep changes staged)git reset --soft HEAD~1⚠️ only if not pushed
Undo a commit with a new "reverse" commitgit revert HEAD✅ yes, always safe
Completely erase last N commitsgit reset --hard HEAD~N🚫 never push after this
🚫
Never force-push to main — it rewrites history and can permanently delete teammates' work. If you need to undo something that was already pushed, use git revert.

The .gitignore File

Tell Git to completely ignore certain files — secrets, build output, OS junk.

.gitignore
🚫
Never commit .env files — they contain API keys, database passwords, and secrets. If you accidentally did, the key is now public. Rotate the key immediately, then remove the file from history using git filter-repo or BFG Repo Cleaner.

Fix Scenarios — Step by Step

🔴 "Help! I committed a secret/password!"
1
Immediately rotate the secret — assume it's already been seen. Generate a new API key.
2
Remove from history with git-filter-repo
3
Add .env to .gitignore before anything else
4
Force-push the cleaned history (coordinate with teammates first):
🟡 "My push was rejected"
! [rejected] main -> main (non-fast-forward)
error: failed to push some refs to 'github.com/...'
hint: Updates were rejected because the tip of your current branch is behind

Fix: Pull first, then push again.

🟡 "I'm in detached HEAD state"

You checked out a specific commit instead of a branch. Any commits you make here will be orphaned.

🟡 "I need to undo my last commit"

Not pushed yet? Remove the commit but keep the changes staged:

Already pushed? Use revert (creates a new commit that undoes the old one):

🎯 Project Task Module 5 — Safety Net
  • Create a .gitignore file and add .env, .DS_Store, __pycache__/
  • Make a "bad" commit, then undo it with git reset --soft HEAD~1
  • Deliberately create a merge conflict, then resolve it correctly
🏥
EmergencyAll Levels

Git Emergency Room

🚑

Walk-in for code emergencies. No appointment needed.

These 7 disasters happen to everyone — including senior engineers. Knowing how to fix them is what separates a beginner from a pro. Click any case to see the full treatment.

#001 🔑 "The Leaked Secret" — committed .env to GitHub 🔴 Critical
SymptomYou pushed code to GitHub and realized your .env file — containing an API key or database password — is now visible to the world.
WhyNo .gitignore was set up. Git tracked everything including secrets.
Fix
🚨
Step 1 first, not last: Rotate the secret immediately. Generate a new API key/password right now — assume the old one is already compromised.
# Remove the file from all Git history
pip install git-filter-repo
git filter-repo --path .env --invert-paths --force
# Then force-push the cleaned history
git push origin main --force
PreventCreate .gitignore as your very first file in every project. Add .env, *.key, config/secrets.* before your first commit.
#002 💣 "The Nuclear Strike" — force-pushed to main 🔴 Critical
SymptomYou ran git push --force on main. Teammates' commits are gone from the remote. Slack is on fire.
WhyForce-push overwrites the remote branch with your local version, erasing any commits that weren't in your local history.
Fix
PreventEnable branch protection rules on GitHub: Settings → Branches → Add rule → check "Require pull request reviews" and "Block force pushes". Force-push only to your personal feature branches, never to main.
#003 👻 "The Detached Ghost" — detached HEAD state 🟡 Moderate
SymptomYou are in 'detached HEAD' state. You make some commits and then switch branches — and your commits vanish.
WhyHEAD normally points to a branch. In detached HEAD, it points directly to a commit. Any new commits aren't on a branch, so they're invisible to git log and eventually garbage-collected.
Fix
PreventAlways git switch <branch-name> to move between branches. Only do git checkout <commit-hash> intentionally for read-only exploration.
#004 🌊 "The Conflict Storm" — merge conflicts in 8 files 🟡 Moderate
SymptomCONFLICT (content): Merge conflict in README.md × 8 files. You panic and close VS Code.
WhyTwo branches edited the same lines. This is not an error — it's Git correctly saying "I can't decide which version wins, human please choose."
Fix
💡
VS Code shows "Accept Current Change / Accept Incoming / Accept Both Changes" buttons right above each conflict. Use them instead of editing markers by hand.
PreventSync with main frequently (git merge main or git pull daily). Small focused branches mean small conflicts. The longer you wait, the worse it gets.
#005 🦕 "The Ancient Branch" — 47 commits behind main 🟢 Minor
SymptomGitHub says "This branch is 47 commits behind main." Your PR has 23 conflicts before you've even started.
WhyYou created a branch and worked on it for weeks without pulling updates from main. Now it's ancient history.
Fix

Or for a cleaner history: replace git merge origin/main with git rebase origin/main.

PreventMake it a habit: every morning, git pull on main, then git merge main into your branch. Five seconds of habit saves hours of conflict resolution.
#006 📦 "node_modules in the Sky" — giant accidental commit 🟡 Moderate
Symptomgit push takes 8 minutes. GitHub shows your repo is 400MB. Your node_modules (or __pycache__, .venv, build output) was committed.
WhyNo .gitignore, so git add . swept up everything including dependency folders.
Fix
PreventThe very first commit in every project should be a .gitignore. GitHub provides templates: when creating a repo, select a .gitignore template for your language.
#007 ✏️ "The Typo Commit" — embarrassing commit message 🟢 Minor
Symptomgit log shows: "Inital comit" or "asdfgh" or "fix stuff maybe idk". Now it's in your public GitHub history.
Fix
PreventUse the convention: <verb> <what> — "Add login page", "Fix null pointer in auth", "Remove unused imports". One sentence, present tense, no period.
Advanced⏱ 45 min

Module 6 · GitHub Actions

What is CI/CD?

Concept
CI (Continuous Integration) = automatically run tests every time code is pushed.
CD (Continuous Deployment) = automatically deploy to production when tests pass.

GitHub Actions lets you automate these workflows directly in your repo using YAML files.
CI/CD Pipeline — what happens after every git push
💻git push
Trigger
📦Install deps
🧪Run tests
Pass → Deploy
Fail → Notify

Anatomy of a Workflow File

.github/workflows/ci.yml

A Workflow for My Tech Wiki — Markdown Linter

.github/workflows/lint.yml

Using Secrets — Don't Hardcode API Keys

1
Add a secret on GitHub

Repository → Settings → Secrets and variables → Actions → New repository secret

2
Use the secret in your workflow

Workflow Triggers Reference

TriggerWhen it runs
pushEvery commit pushed to any matching branch
pull_requestWhen a PR is opened, updated, or merged
scheduleOn a cron schedule (e.g., every day at 9am)
workflow_dispatchManually via the GitHub UI
releaseWhen you publish a GitHub Release
⚠️ Common Issues — Module 6

YAML indentation errors — YAML is very sensitive to spaces (not tabs). Use a YAML linter: paste into yamllint.com before committing.

"Workflow not triggering" — Check that the file is at exactly .github/workflows/filename.yml (plural "workflows").

Workflow passes locally but fails in CI — The CI environment is fresh every time. Make sure you install all dependencies in a run step; don't assume anything is pre-installed.

Secrets show as "***" in logs — That's correct behavior. If you're not seeing them at all, make sure the secret name in the YAML matches exactly (case-sensitive).

🎯 Project Task Module 6 — Add GitHub Actions
  • Create .github/workflows/lint.yml with the Markdown linter above
  • Commit and push — watch the Action run on GitHub → Actions tab
  • Introduce a markdown error, push, watch the Action fail
  • Fix the error, push again, see the Action turn green ✅
🚀
Advanced⏱ 40 min

Module 7 · Advanced Git

git stash — Save Work Without Committing

Stash is like a temporary drawer. Useful when you need to switch branches but aren't ready to commit.

git rebase — Cleaner History

Merge vs Rebase
Merge creates a merge commit that joins two histories — good for shared branches.
Rebase replays your commits on top of another branch — creates a clean linear history. Better for personal feature branches before a PR.
git merge A B C D M merge commit git rebase A B C' D' linear — no merge commit
⚠️
Never rebase a branch other people are using. Rebase rewrites commit hashes, which breaks everyone else's copy.

Powerful git log

Tags & Releases

On GitHub, go to Releases → Create a new release and pick a tag to publish an official release with notes and downloadable assets.

Git Aliases — Type Less

git bisect — Find Which Commit Broke Something

🎯 Project Task Module 7 — Polish & Release
  • Run git log --oneline --graph --all to see your full project history
  • Add 3 git aliases to your config
  • Create a tag: git tag -a v1.0 -m "Initial wiki complete" and push it
  • Publish a GitHub Release from the tag with release notes
📋
Reference

Cheat Sheet

Setup
git config --global user.name "X"Set your name
git config --global user.email "X"Set your email
git config --listShow all config
Create & Initialize
git initCreate a new repo
git clone <url>Clone from GitHub
Staging & Committing
git statusWhat's changed?
git add <file>Stage a file
git add .Stage everything
git commit -m "msg"Save a snapshot
git commit --amendFix last commit
Branches
git branchList branches
git switch -c <name>Create & switch
git switch <name>Switch branch
git merge <branch>Merge into current
git branch -d <name>Delete branch
Remote
git remote -vShow remotes
git remote add origin <url>Add remote
git push -u origin mainFirst push
git pushPush changes
git pullPull changes
git fetchDownload (no merge)
Undoing
git restore <file>Discard changes
git restore --staged <file>Unstage
git reset --soft HEAD~1Undo commit, keep files
git revert HEADSafe undo (new commit)
Inspecting
git log --onelineCompact history
git log --graph --allVisual branch graph
git diffUnstaged changes
git diff --stagedStaged changes
git show <hash>Show a commit
git blame <file>Who changed each line
Advanced
git stashStash dirty work
git stash popRestore stash
git rebase <branch>Rebase onto branch
git cherry-pick <hash>Apply one commit
git tag -a v1.0Create annotated tag
git bisect startBinary search for bug