Skip to content

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)

ref (branch) -> commit -> tree -> (tree|blob) ...
                 |
               parent(s)

Visual guide (staging)

working tree --(git add)--> index --(git commit)--> repo

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
  • --soft vs --mixed vs --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 reflog give 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 -sb tell you?
  • Short status + branch tracking info (ahead/behind).
  • How do you inspect what changed in a commit?
  • git show <sha> (or git 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 fetch then rebase/merge from main; resolve; run tests.

History editing (easy -> hard)

  • When do you use revert instead of reset?
  • 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 --amend does what?
  • Replaces last commit (new SHA) with updated content/message.
  • Why --force-with-lease over --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 --abort or use reflog to 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