How fabiogen1966/git-samples works
Project Type and Purpose
• This repository is an open-source educational tool—a suite of Git exercises. Each top-level folder (e.g., basic-branching, basic-commits, basic-revert, etc.) is a self-contained hands-on lesson. Utility scripts in the utils folder orchestrate setup, test harnesses, and resource provisioning for all exercises.
File Structure Analysis
• Top-Level Directories
• Each exercise directory (bad-commit, basic-branching, …) contains:
– README.md — exercise instructions
– setup.sh / setup.ps1 — scripts to initialize the exercise repo
– (occasionally) an exercise subfolder with initial files
• utils — shared tooling for generating bare repositories, cloning, seeding resources, and running tests
– clone-remote-to-exercise.*
– make-bare-remote-repo.*
– make-exercise-repo.*
– make-setup.sh (discovers all exercises, invokes setup scripts)
– resources/merge-tst-files.sh — sample files used in merge exercises
– test/test_setup.sh — verifies each setup ran correctly
• No frontend/backend split: this is a CLI/script-based system.
• Core dependencies: POSIX shell (bash), PowerShell for Windows, Git CLI.
README Insights
• Top-level README is stub (“a”), no architecture description. We infer architecture from the file layout and patterns in utils and exercise folders.
a. Main Components
• User Environment (Windows or Unix shell)
• Git CLI
• Utils Module
– Setup Orchestrator (make-setup.sh / .ps1)
– Repo Generators (make-bare-remote-repo, make-exercise-repo)
– Resource Providers (utils/resources)
– Test Harness (utils/test)
• Exercise Repositories (one per lesson)
b. Relationships & Interactions
1. User invokes a top-level setup.sh / setup.ps1
2. The orchestrator script loops through each exercise folder:
– Calls make-bare-remote-repo → creates a bare Git repo in /tmp or exercise-specific path
– Calls make-exercise-repo → clones the bare repo, checks out branches, seeds initial commit files (from utils/resources or exercise/exercise)
3. The orchestrator invokes clone-remote-to-exercise to simulate “remote” and “local” remotes.
4. Once setup is complete, the test harness (utils/test/test_setup.sh) runs Git commands and validates the state matches expected exercise preconditions.
5. User now cd’s into an exercise folder and performs Git commands to solve the task.
c. Architectural Patterns & Design Principles
• Modularity: shared logic lives in utils, exercise-specific logic stays in each folder.
• Script orchestration: a single entrypoint (make-setup.sh) that discovers and initializes all exercises.
• Reproducibility: bare-repo pattern ensures clean, repeatable state.
d. Key Technologies
• Shell scripting (bash) & PowerShell
• Git CLI (init, clone, commit, branch, push/pull)
• POSIX utils (cp, rm)