EmmEEdu
Version Control Hub

Git & GitHub Learning Center

Visual staging area workflows, commit snapshots, branching models, and destructive command safeguards.

Interactive Git Tree Simulator

Git 4-Stage Lifecycle Architecture

Working Directory → Staging Area (Index) → Local Repository → Remote Repository (GitHub)

$Repository clean. 2 files modified in working tree.
1. Working Tree2 modified
app/page.tsx
styles/theme.css
Unstaged local edits on disk
2. Staging Area (Index)0 staged
Nothing staged to commit
Prepared for snapshot
3. Local Repo (.git)HEAD @ 9a2f10b
9a2f10bHEAD
initial commit: project scaffold
Committed to local DAG
4. Remote (GitHub)origin/main
9a2f10bmain
initial commit: project scaffold
Synced with GitHub

What is Git? (Local Tool)

Git is an open-source distributed version control system installed on your local computer. It operates completely offline, tracking file changes as content-addressable snapshots in the hidden .git folder.

What is GitHub? (Cloud Platform)

GitHub is a cloud hosting platform for Git repositories. It layers collaboration features on top of Git: Pull Requests, Issue tracking, Code Review workflows, GitHub Actions CI/CD pipelines, and project boards.

Command Reference & Safeguards

Git Command Center & Danger Analyzer

Search syntax, flags, internal repository mechanics, and safety levels to prevent accidental data loss.

git initInitialize Repository
Safe

Creates an empty Git repository or reinitializes an existing one by creating a hidden .git directory.

git init [directory] [--initial-branch=<branch>]
git init
Initializes a repository in the current working directory.
git init my-app -b main
Creates a directory named my-app with default branch 'main'.
Common Options & Flags:
-b, --initial-branch <name>Use the specified name for the initial branch (e.g. main).
--bareCreate a bare repository (no working directory, for shared servers).
Internals: Creates the .git folder containing objects database, refs/heads, HEAD file, config, and hooks directory.
git addAdd to Staging Area
Safe

Updates the index (staging area) using the current content found in the working tree, preparing files for the next commit.

git add <pathspec>...
git add .
Stages all modified and new files in the current repository.
git add -p src/app.ts
Interactively choose hunks of patch to stage line by line.
Common Options & Flags:
-A, --allStage all files including modifications, untracked, and deletions.
-p, --patchInteractively choose hunks of patch between index and work tree.
-u, --updateStage only already-tracked modified and deleted files.
Internals: Calculates SHA-1/SHA-256 hash of file contents, writes blob object to .git/objects, and updates the index file.
git commitRecord Changes to Repository
Safe

Captures a snapshot of the project's currently staged changes and records it into the permanent commit graph with author details and a log message.

git commit -m "<message>" [options]
git commit -m "feat: implement REST visualizer packet flow"
Commits staged changes with a descriptive message following Conventional Commits.
git commit --amend --no-edit
Adds newly staged changes into the most recent commit without changing message.
Common Options & Flags:
-m <msg>Set the commit message directly from CLI.
-a, --allAutomatically stage modified/deleted tracked files before committing.
--amendReplace the tip of the current branch by creating a new commit.
Internals: Creates a tree object representing the directory snapshot, points a commit object to that tree and parent commit SHA, and advances the current branch ref.
git rebaseReapply Commits on Top of Another Base
Caution
WARNING: Rewrites commit history! Never rebase commits that have already been pushed to a public/shared branch.

Re-applies commits on top of another base tip, creating a linear history instead of merge bubbles.

git rebase [-i] <upstream> [branch]
git rebase main
Reapplies current feature branch commits onto the latest tip of main.
git rebase -i HEAD~3
Launches interactive rebase editor to squash, edit, or reorder the last 3 commits.
Common Options & Flags:
-i, --interactiveLet the user edit the list of commits to rebase (squash, drop, reword).
--continueRestart the rebasing process after resolving a merge conflict.
--abortAbort the rebase operation and reset HEAD to the original branch state.
Internals: Temporarily stores feature commits as patches in .git/rebase-apply, resets branch to base, and applies patches one-by-one.
git reset --hardHard Reset Working Tree & Index
Destructive
WARNING: DESTRUCTIVE: Unstaged and uncommitted changes will be PERMANENTLY lost and cannot be recovered from git reflog!

Resets the index and working tree. Any changes to tracked files in the working tree since <commit> are discarded permanently.

git reset --hard [<commit>]
git reset --hard HEAD
Discards all uncommitted changes in tracked files and matches working tree to HEAD.
git reset --hard origin/main
Forces local branch to match the remote repository state exactly, discarding local commits.
Common Options & Flags:
--hardResets the index and working tree. Any changes in the working tree are discarded.
--softDoes not touch index or working tree; only moves the HEAD branch pointer.
--mixedDefault mode: resets the index but not the working tree.
Internals: Overwrites working tree files and staging area index with the contents of the target commit snapshot and moves the ref pointer.
git reflogReference Logs (The Git Undo Safety Net)
Safe

Reference logs record when the tips of branches and other references were updated in the local repository. Enables recovering 'lost' commits from bad rebases or hard resets.

git reflog [show] [<ref>]
git reflog
Shows local commit history including HEAD movements, resets, merges, and checkouts.
git reset --hard HEAD@{1}
Undoes the last destructive action by restoring HEAD to its previous position.
Common Options & Flags:
showShows the log of the reference (default is HEAD).
expirePrunes older reflog entries (usually kept for 90 days).
Internals: Reads entries in .git/logs/HEAD tracking every pointer update with old SHA, new SHA, committer, and action reason.