Building Apps with AILesson 39 of 87

Module 5 · Save points, and shipping to a stranger

Three ways back, and the undo for undo

In this lesson

  • 9 min read
  • 7 reading sections
  • Knowledge check
  • Lesson 3 of 11 in this chapter

This chapter’s goalKeep a project in git well enough to undo any hour (stage part of a change, restore one file, revert a pushed commit, recover from a bad reset, branch for an agent’s work and merge it back) and put the app on a free host with a real domain, environment variables scoped per environment, and a version stamp that says which commit is live.

This chapter’s media

The film explains chapter ideas. The audiobook narrates the complete teaching text.

FormatEnglishहिंदी
Chapter filmNot availableNot available
Full audiobookNot availableNot available
Which way back, and whether it has been pushedOne file backOne commit undoneNot pushedrestorenothing else movesreset --hardlater commits abandonedAlready pushedrestorenothing else movesrevertthe only safe undoReset moves your branch pointer and abandons what came after it. The remote still holds those commits,so the next push is rejected and the suggested fix online is a force push that deletes them from theonly other copy.
Reset moves your branch pointer and abandons what came after it. The remote still holds those commits, so the next push is rejected and the suggested fix online is a force push that deletes them from the only other copy.

Figure

A little at a time

Explore an idea, try it, then check what stays.

Step 1 of 8Free · no account needed
Lesson steps

Looking before moving

The earlier lesson on finding the change that broke it gave you git log -p -- file and bisecting. Two more reading commands belong beside them, because most people reach for a destructive command when a reading one would have answered the question.

Bash
git show a3f9c21                     # one commit: message plus its full diff
git show a3f9c21:src/booking.ts      # one file, exactly as it was then
git log -S "cancelBooking" --oneline # commits that added or removed that text

That last one is the pickaxe. When a function has vanished and nobody remembers deleting it, -S finds the commit where the string stopped appearing. It searches content, not messages, so it works even when every message says “update”.

HEAD means “where I am now”. HEAD~1 is its parent, HEAD~3 three commits back. git diff HEAD~3 is everything since then.

Your place and first choices stay on this browser. Classroom credit is recorded separately.

Every lesson here is open. Your progress is recorded once you pass the Building with AI exam.

Stuck on something?Ask Beatriz, your AI tutor

How to cite: Addaly (2026) ‘Three ways back, and the undo for undo’, in Building Apps with AI. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/building-apps-with-ai/three-ways-back (Accessed: 29 November 2026).