harbor run -t LiteCoder/git-disaster-recovery-simharbor download LiteCoder/git-disaster-recovery-simSimulate a Git disaster-recovery scenario: build a repository with both pushed and unpushed work, destroy the local .git directory, then recover as much history as possible from the remote. Finally, produce a JSON report documenting what was recovered and what was lost.
/app/app/recovery_report.jsonCreate the "remote" repository
/app/remote_repo.git to act as the team's shared remote.Create the local working repository
/app/local_repo./app/remote_repo.git as a remote named origin.Build main-branch history (pushed)
main branch in /app/local_repo, create at least 3 commits, each adding or modifying at least one file. The commit messages must follow the pattern main-commit-N where N is 1, 2, 3, …main branch to origin.Create feature branches with unpushed commits
main commit:
feature-alpha — with at least 2 commits (messages: alpha-commit-1, alpha-commit-2, …). Do not push this branch.feature-beta — with at least 2 commits (messages: beta-commit-1, beta-commit-2, …). Push this branch to origin./app/pre_disaster_refs.json with the structure below)./app/pre_disaster_refs.json format:
{
"main": "<full-sha>",
"feature-alpha": "<full-sha>",
"feature-beta": "<full-sha>"
}
Simulate the disaster
/app/local_repo/.git directory (simulating rm -rf .git).Recover from remote
/app/remote_repo.git into a new directory /app/recovered_repo./app/recovered_repo, list all branches (local + remote-tracking) and all reachable commits.Attempt local-only recovery
/app/recovered_repo, run git fsck and git reflog to look for any dangling objects.Generate the recovery report
Write /app/recovery_report.json with the following structure:
{
"recovered_branches": ["<branch-name>", ...],
"lost_branches": ["<branch-name>", ...],
"recovered_commits": {
"<branch-name>": ["<commit-message>", ...]
},
"lost_commits": {
"<branch-name>": ["<commit-message>", ...]
},
"recovery_method": "<brief description of how recovery was performed>",
"lessons_learned": ["<lesson-1>", "<lesson-2>", ...]
}
Rules for the report:
recovered_branches: branches whose full commit history is present in /app/recovered_repo. Must include main and feature-beta.lost_branches: branches that could not be recovered. Must include feature-alpha.recovered_commits: map each recovered branch name to an array of its commit messages (in chronological order, oldest first).lost_commits: map each lost branch name to an array of its commit messages (in chronological order, oldest first).lessons_learned: at least 2 non-empty strings./app/remote_repo.git exists and is a valid bare Git repository./app/recovered_repo exists and is a valid Git repository cloned from the remote./app/local_repo/.git does not exist (disaster was simulated)./app/pre_disaster_refs.json exists and contains valid full-length SHA-1 hashes for all three branches./app/recovery_report.json exists, is valid JSON, and conforms to the schema above.main branch commits (main-commit-1, etc.) and feature-beta commits (beta-commit-1, etc.) are present in /app/recovered_repo.feature-alpha commits are not present in /app/recovered_repo (they were never pushed and the local .git was destroyed).