Objective & prerequisites
Distinguish a new reversing commit from discarding working edits. Prerequisites: basic Python expressions and files; use a disposable local practice folder and fictional data. This shared workshop complements the existing data/AI tracks and does not create a second progress system.
Understand the concept
A revert creates another commit that applies the inverse of an earlier change. It preserves an inspectable history and differs from commands that discard working files or move branch pointers. Recovery policy depends on whether work is local, shared or already released; never experiment with destructive commands on a production checkout.
Worked example
The reference reverts the single feature commit after a fast-forward. README.txt returns to its original content, but the repository now has three commits. The previous feature remains in history.
python3 foundation_labs.py FoundationTests.test_gitTry it yourself
Run the Git test and reconcile final content with commit count. Write a recovery note for a mistake in a team change; state which files and evidence would need review. Record your prediction before running the supplied reference, then compare the observed result and explain any difference.
Worked solution
Final content is the original fictional analysis brief; three commits record initial content, added control and reversal. The command works for the single non-merge commit in this controlled fixture. Reverting a merge has additional parent semantics and is outside this first lab.
Knowledge check
Does revert remove a secret from all prior commits? Try answering without rereading the example.
Check and explain
No. Reverting does not erase history. An exposed credential needs a separate incident response and rotation under the owner’s policy.
Mini-project, mistakes & handover
Produce a short README with the question, exact local command, input meaning, checks and actual results. Include one failure case and its explanation. Never silently turn an exception into a passing result. Mark simulated behavior explicitly, credit the supplied teaching code and identify your own contribution. These activities are unsaved self-practice, not certification.
Authoritative reference
— consulted for the underlying interface/concept. The lesson and fictional examples are original teaching material. Python reference tested with 3.12; designed for 3.10+. Git lab requires Git 2.28+.
Try the activity before reading its reference. Keep your sources, commands and assumptions with your work. Companion activities are unsaved self-practice and do not award a certificate or change lesson progress.