NonDev Apps

Day 18 of 21

GitHub safety - branches, commits, and how to undo changes

Goal: When Codex changes files, those changes happen directly on your computer. Without GitHub, one wrong Codex session could overwrite weeks of work with no way back. Today you learn to use GitHub Desktop — the safest, most visual way to manage your project — to create branches, commit working changes, review what Codex did, and safely undo changes when something goes wrong.

What to do

01

Understand what a branch is

A branch is a complete copy of your project that lives alongside the original. When you create a branch and let Codex work on it, your original "main" copy stays untouched. If Codex breaks something on the branch, you simply switch back to main — and everything is as it was before. Think of it as a scratch pad that you can throw away without losing your real work.

02

Create a branch in GitHub Desktop

Open GitHub Desktop. Make sure your project is selected in the top-left dropdown. Click "Current Branch" at the top of the screen — it probably shows "main". Click "New Branch." Type a short name that describes what you are working on today, for example: "day-18-practice" or "try-new-feature". Click "Create Branch." GitHub Desktop will switch you to the new branch automatically.

03

Make a small change and commit it

Now make one tiny change to a file manually — open any file in your project in a text editor, change one word, and save it. Then switch to GitHub Desktop. You will see the changed file appear in the left panel under "Changes." In the bottom-left box, type a short commit message describing what you changed — for example: "Change one word in homepage heading." Then click "Commit to day-18-practice."

04

Review what changed using the diff view

In GitHub Desktop, click on the changed file in the left panel. The right side of the screen shows the diff — a line-by-line comparison of what changed. Lines with a green background and a + symbol are new additions. Lines with a red background and a - symbol were removed. Read the diff before committing anything. This is how you check what Codex actually did.

05

Discard a change safely

Sometimes you will want to undo a change before committing it. In GitHub Desktop, right-click the changed file in the left panel and choose "Discard Changes." GitHub Desktop will warn you that this cannot be undone. Read the warning carefully before clicking "Discard Changes" again to confirm. WARNING: only discard if the file has not been committed — once committed, use the revert step instead.

06

Revert a committed change using History

If you committed a change and then realised it was wrong, you can revert it. In GitHub Desktop, click "History" in the left panel to see your past commits. Find the commit you want to undo. Right-click it and choose "Revert Changes in Commit." GitHub Desktop creates a new commit that undoes the previous one — your project returns to its earlier state. WARNING: only do this on your working branch, not on main.

Expected result

You created a branch in GitHub Desktop, made a commit on it, reviewed a diff, discarded an uncommitted change, and practiced reverting a commit. You now have a complete safety workflow for every Codex session.

Key takeaway

  • Always create a branch before letting Codex work. Always review the diff before committing. Discard discards uncommitted changes. Revert undoes committed changes. These four actions are your complete undo system — and they all live in GitHub Desktop.
Day 18 - GitHub safety - branches, commits, and... - NonDev Apps