Rullst AcademyRullst Academy/Lesson
Git: every change counts · Lesson 08 / 10

Correct without erasing the path

Corrections need not erase what happened. We will unstage a selection and then undo a commit with another commit.

Learning paths14 min

Let's discover together

  1. 1

    After completing merge and checking clean status, append camera to ideas.txt, save and stage. To review further, git restore --staged -- ideas.txt unstages it using the last commit as reference.

  2. 2

    The working file keeps camera. Verify in the editor and git diff. --staged matters: restore without it can replace the working file and discard an edit. Do not interchange them by guesswork.

  3. 3

    For the second experiment, stage again and commit Add camera. The change is now in history. In a clean workshop, git revert --no-edit HEAD creates a commit undoing the latest ordinary commit. Here HEAD must be Add camera, not the merge commit.

  4. 4

    The original commit stays in log; the new one records correction. Revert can conflict in other situations; stop and read status if that happens. It is not a tool for removing secrets from old commits.

GIT · .md

Your change laboratory

This page’s experiments show prepared outputs. To run real commands, use a new practice folder on your computer and the guide included in “Download activity”. Read the instructions before each command.

My files and GitHub

The editor below saves your Markdown notes in this browser. Download a copy to take them to another device. Sending that file to GitHub does not send your computer’s .git history.

FROM LESSON TO PRACTICE

A guide to follow at your pace

Read the steps before using the reference below. Commands run in the indicated system’s terminal; signup happens on the official site. Rullst Academy exercises are practice and do not verify your installation or external account.

git restore --staged -- ideas.txt
git diff -- ideas.txt
git add ideas.txt
git commit -m "Add camera"
git status
git log -1 --oneline
git revert --no-edit HEAD
git log -2 --oneline

Official links and next step

✦
YOUR MISSION

Distinguish restore --staged from revert and preserve files/history.

Now it's your turn

Discovery workshop

Read the state, choose the next step

First, camera was added, saved and staged in ideas.txt: we only unstage it. Later, at another moment in the workshop, that edit has become the Add camera commit and git revert --no-edit HEAD has already finished; we read the new commit’s message. Prepared outputs.
Mini experiment

Learning simulation: compare cards and check your predictions. The browser is not compiling Rust or starting a server.

git restore --staged -- ideas.txt
git status --short -- ideas.txt
Build your answers and check when you are ready.
A moment to understand

What does revert do in this example?

I need a hint

Revert records an inverse change; it does not eliminate the previous commit.

Loading your journey…

Take it with you

Check that camera remains after unstaging and disappears after reverting Add camera. Compare commit counts before/after: revert should add one.

At your own pace

My files and GitHub

Every lesson can become your own record: code, notes or a practice plan. Saving a file to GitHub is optional and does not change your XP.

Student guide

The editor and downloads open when this lesson is available to your account. Check access below or return to the track map.

Checking your access to this lesson…

Rullstpetbot

AI can make mistakes. Check the lesson material.