PAITS Cheat Sheet Software Engineering Beginner Updated 2026-10-23

Git Internals, Content-Addressable DAG & CI/CD Release Engineering

Blobs, trees, commits, rebase vs merge, interactive bisect, reflog recovery, and immutable artifact pipelines.

Executive Summary: Under-the-hood reference for Git's Merkle-DAG object model (`.git/objects`), surgical history recovery with `git reflog`, automated regression hunting with `git bisect run`, and trunk-based CI/CD.

Key Equations & Invariants

Git Object Content-Addressed Hash
\text{OID} = \text{SHA-1}\bigl(\text{type} \mathbin{\|} \text{' '} \mathbin{\|} \text{size} \mathbin{\|} \text{'\textbackslash 0'} \mathbin{\|} \text{payload}\bigr)

Every blob, tree, commit, and annotated tag is immutably addressed by the hash of its header + content.

1. Git Object Model & Emergency Recovery Commands

Because Git commits are immutable snapshots in a Directed Acyclic Graph (DAG), a 'hard reset' or botched rebase never immediately deletes committed data—it only moves branch pointer refs (`HEAD`).

ScenarioCommandMechanism
Recover lost commit after git reset --hardgit reflog && git reset --hard HEAD@{2}Reads local reference transaction log
Find exact commit that broke testsgit bisect start HEAD v1.2.0 && git bisect run pytestBinary searches commit DAG in O(log N) steps
Safe force-push on rebased feature branchgit push --force-with-leaseRejects push if remote ref advanced since last fetch
Cleanly undo a public commit on maingit revert -m 1 <commit-sha>Appends inverse diff commit without rewriting history

Common Production & Interview Pitfalls

Frequently Asked Questions

Q: How does git store files: as diffs or as full snapshots?

Logically, every Git commit points to a full tree snapshot of blobs (unchanged files share existing blob SHA pointers). Physically, `git gc` later delta-compresses similar blobs inside `.pack` files.