GitSim
GitSimA visual simulator for learning Git.

Git glossary

Plain-English reference for the Git commands you'll meet most often, plus the short workflows that string them together. Use the simulator tab to watch the graph move while you run them.

Inspecting state

git status

git status

Shows which files are untracked, staged, or modified.

When: Run constantly. It's the cheapest way to know what Git thinks is going on.

git log

git log --oneline --graph --all

Walks the commit history backwards from HEAD through parents.

When: When you need to see what's been committed, by whom, and how branches diverge.

git diff

git diff [--staged]

Shows line-by-line changes between working tree, index, and HEAD.

When: Before staging or committing, to review what you're about to record.

Saving work

git add

git add <file> · git add .

Copies the current contents of a file into the index (staging area).

When: When you've made edits you want to include in the next commit.

git add src/App.tsx

git commit

git commit -m "message"

Snapshots the index as a new commit and advances the current branch pointer.

When: Once a unit of work is staged and the message describes the change in one line.

git commit -m "fix: handle empty cart state"

git stash

git stash · git stash pop

Tucks uncommitted changes onto a side stack so the working tree becomes clean.

When: You need to switch branches but aren't ready to commit.

Branches

git branch

git branch · git branch <name>

Lists branches, or creates a new movable pointer at the current commit.

When: Before starting work that's separate from main.

git checkout / git switch

git checkout -b <name> · git switch <name>

Moves HEAD to a different branch and updates the working tree to match.

When: Switching contexts, or starting a feature branch with -b.

git merge

git merge <branch>

Joins another branch into the current one. Fast-forwards if possible, otherwise creates a merge commit.

When: Bringing a feature branch into main, or pulling upstream changes locally.

git rebase

git rebase <branch>

Replays your commits on top of another branch, producing a linear history.

When: Updating a feature branch with main without creating merge commits.

Remotes

git clone

git clone <url>

Copies a remote repo locally: commits, branches as remote-tracking refs, and a checkout of the default branch.

When: First time you work on a repo.

git fetch

git fetch

Updates your local view of the remote (origin/*) without changing your branches or working tree.

When: When you want to see what changed on the remote before deciding to merge.

git pull

git pull

Fetch + merge in one step: updates origin/* and merges the matching upstream branch into yours.

When: You're up to date locally and want to grab the latest changes.

git push

git push · git push -u origin <branch>

Uploads your new commits and fast-forwards the matching branch on the remote.

When: After committing locally and you're ready to share or open a PR.

Undoing things

git reset

git reset --soft|--mixed|--hard HEAD~1

Moves the current branch pointer backwards. --soft keeps index, --mixed keeps working tree, --hard clobbers both.

When: Rewriting recent local history. Avoid on commits you've already pushed.

git revert

git revert <commit>

Creates a new commit that undoes the changes of an earlier commit.

When: Reversing a commit that's already public — safer than reset.

git restore

git restore <file>

Discards working-tree changes, restoring the file from the index (or a commit).

When: You want to throw away local edits to a file.

Setup & config

git init

git init

Turns the current directory into a Git repo by creating a hidden .git folder.

When: Starting a brand-new project that isn't cloned from somewhere.

git config

git config --global user.name "Your Name"

Reads or writes Git settings (identity, editor, aliases, default branch name).

When: First-time setup on a new machine, or tweaking behavior per-repo.

git config --global user.email "you@example.com"
git config --global init.defaultBranch main

git remote

git remote -v · git remote add origin <url>

Lists or manages the named URLs Git pushes to and fetches from.

When: Connecting a fresh local repo to GitHub, or pointing at a new fork.

.gitignore

echo 'node_modules' >> .gitignore

A file listing path patterns Git should never track (build output, secrets, deps).

When: Before your first commit — once a file is tracked, .gitignore won't untrack it.

History & inspection

git show

git show <commit>

Displays the message, author, and full diff of a single commit.

When: You want to inspect exactly what one commit changed.

git blame

git blame <file>

Annotates each line of a file with the commit and author that last touched it.

When: Tracking down when (and why) a specific line was introduced.

git reflog

git reflog

A local log of everywhere HEAD has been — including resets and rebases.

When: You think you lost work after a reset/rebase. Almost everything is recoverable from here.

git bisect

git bisect start · git bisect good <sha> · git bisect bad

Binary-searches your history to find the commit that introduced a bug.

When: A bug appeared somewhere in the last N commits and you don't know which.

Tags & releases

git tag

git tag -a v1.0.0 -m "First release"

Creates a named, immutable pointer to a specific commit — usually a release.

When: Marking a shipped version so you can come back to it later.

git push --tags

git push origin v1.0.0 · git push --tags

Tags aren't pushed by default — this uploads them to the remote.

When: After tagging a release locally and you want GitHub to show it too.

Rewriting & moving commits

git cherry-pick

git cherry-pick <commit>

Applies the changes from one commit on top of your current branch as a new commit.

When: You want one specific commit from another branch without merging the whole thing.

git rebase -i

git rebase -i HEAD~5

Interactive rebase: reorder, squash, edit, or drop commits before sharing them.

When: Cleaning up messy local history before opening a PR.

git commit --amend

git commit --amend -m "better message"

Replaces the most recent commit with a new one (new message and/or new changes).

When: You forgot a file or want to fix the last commit message. Don't amend pushed commits.