How halo0516/gitlet works
Project type and purpose
• This is a command‐line, single‐user version-control system implemented in Java (a “Gitlet”), mimicking a subset of Git’s local features (init, add, commit, checkout, log, branch, merge, status, rm, reset, find).
File structure
• Top level:
• Makefile, README.md, .gitignore
• gitlet/ directory containing all Java source files and tests.
• In gitlet/:
• Main.java: CLI entrypoint, argument parsing, dispatch to commands
• One class per command: Init, Add (implied inside Stage), Commit, Checkout, Log, GlobalLog (in Log), Find, Branch, Merge, Reset, Stage, Remove (rm), Utils, plus GitletException
• Data classes: Commit (models commit metadata), Stage (models staging area), Utils (handles SHA-1 hashing, file I/O), Branch (manages branch refs)
• Tests: GitletTest, LocalTest, UtilsTest
README for additional insights
• Describes the .gitlet directory structure: subdirs for commits, branches, staging area, and removed files
• Explains use of linked lists and trees to represent commit history and branches
• Notes SHA-1 hashing for object IDs
Detailed capture of essential elements
• .gitlet directory as persistent storage block.
• Commit objects flowing into commits/ subdirectory.
• Branch refs (text files) in branches/.
• Staging index in stage/ and removed file records in remove/.
• How Merge command reads two commit DAG branches and writes a merged Commit.
• How commands use services which use Utils to manipulate the .gitlet directory
• SHA-1 hashing step in Utils when writing Commit objects
• Commit tree (linked nodes) and branch pointers (refs) within the persistence layer to illustrate branching/merging