Portal | Level: L0: Entry | Topics: Git | Domain: DevOps & Tooling
Git - Skill Check¶
Mental model (bottom-up)¶
Git is a content-addressed object database plus refs (names) that point at commits. A commit points to a tree (directory snapshot) which points to blobs (file content).
Visual guide (object graph)¶
Visual guide (staging)¶
Glossary¶
- blob - file content object
- tree - directory listing: names -> blobs/trees
- commit - points to a tree + parents + message
- ref - name pointing to a commit (branch/tag)
- HEAD - your current checkout pointer
- index - staging area (what will be committed)
- reflog - local history of where refs/HEAD pointed
Common failure modes¶
- "I lost commits" (you didn't; use
reflog). - Rewriting shared history without
--force-with-lease. - Giant unreviewable commits (future-you hates you).
Roadmap core (10, easy -> hard)¶
- What is a commit (really)?
- Snapshot pointer + metadata + parent refs.
- What is HEAD?
- Pointer to current ref/commit you're "on".
- What's in
.git/objects/? - Compressed blobs/trees/commits/tags addressed by hash.
- Merge vs rebase?
- Merge preserves history; rebase rewrites for linear history.
- Undo last commit, keep staged?
git reset --soft HEAD~1- Undo last commit, discard changes?
git reset --hard HEAD~1--softvs--mixedvs--hard?- Soft: move HEAD; Mixed: unstage; Hard: wipe working tree too.
- Rebase conflict workflow?
- Fix ->
git add->git rebase --continue(or--abort) - Safest way to rewrite pushed history?
- Prefer revert; if forced:
git push --force-with-lease. - What does
refloggive you? - Local history of ref movement; recovery from "lost" commits.
Day-to-day collaboration (easy -> hard)¶
- What's the difference: fetch vs pull?
- Fetch updates refs; pull = fetch + merge/rebase.
- What is a "clean working tree" and why care?
- No unstaged/staged changes; safer for merges/rebases.
- What does
git status -sbtell you? - Short status + branch tracking info (ahead/behind).
- How do you inspect what changed in a commit?
git show <sha>(orgit diff <sha>^!).- How do you keep PRs reviewable?
- Small commits, clear messages, avoid drive-by formatting.
- How do you update a feature branch safely?
git fetchthen rebase/merge from main; resolve; run tests.
History editing (easy -> hard)¶
- When do you use
revertinstead ofreset? - When changes are already shared; revert is additive and safe.
- What's the risk of interactive rebase?
- Rewrites SHAs; breaks others if pushed/shared.
git commit --amenddoes what?- Replaces last commit (new SHA) with updated content/message.
- Why
--force-with-leaseover--force? - Refuses to clobber if remote moved unexpectedly.
- What's a "fixup" commit?
- Marked commit intended to be squashed automatically later.
- How do you recover from a bad rebase?
git rebase --abortor usereflogto reset to pre-rebase SHA.
Branching & merging semantics (easy -> hard)¶
- Fast-forward vs merge commit?
- FF moves pointer; merge commit records topology explicitly.
- Why rebase can simplify blame?
- Linear history; fewer merge commits.
- Why merge preserves context?
- Retains branch structure; useful for audit/troubleshooting.
- What's a "conflict" really?
- Git can't auto-merge overlapping line edits; you choose resolution.
- How do you reduce conflicts?
- Rebase often, small diffs, avoid long-lived branches, isolate refactors.
Sources¶
- git-scm.com official docs and Pro Git book.
- https://git-scm.com/docs
- https://git-scm.com/book/en/v2
Wiki Navigation¶
Related Content¶
- Git Advanced (Topic Pack, L2) — Git
- Git Drills (Drill, L0) — Git
- Git Flashcards (CLI) (flashcard_deck, L1) — Git
- Git for DevOps (Topic Pack, L0) — Git
- Interview: Secret Leaked to Git (Scenario, L2) — Git
- Mental Models (Core Concepts) (Topic Pack, L0) — Git
- RHCE (EX294) Exam Preparation (Topic Pack, L2) — Git
- Repository Flashcards (CLI) (flashcard_deck, L1) — Git
- Track: Foundations (Reference, L0) — Git