TOPIC 05/1816 MINNOT STARTED

Git ignore and undo: keep files out and fix mistakes safely

Learn how to keep secrets and noise out of Git with a gitignore file, and how to undo a change at each of the three places, so a slip is a small thing to fix.

L1–L4 are part of the Pro pass

L0 Explain simply

Analogy: packing a suitcase with a leave-behind list and correction slips. A list on the door says what never goes in the case, such as the house keys. If you pack something wrong, you can take it out of the open case or out of the closed case. You can also send a correction slip after the trip has started.

Where you notice decides which fix to use.

Tom, a tester at Daily List, a to-do list app, keeps two kinds of files out and fixes slips at the right place.

What it is: Git records snapshots of tracked project files and available commit history, with who saved each version and when. It runs on your own computer and works without the internet. GitHub is a different thing: a website that stores Git projects so a team can share them. This topic covers two small parts of Git. A .gitignore file lists the files Git must leave out. The undo commands fix a mistake, and which one you use depends on where the mistake sits.

Why it matters: A secret in a commit, such as a password or a key, can hurt the whole team, because the history keeps it. A bad undo can throw away a day of work. Tom knows the ignore rules and the right undo for each place, so a slip stays a small thing to fix.

PLAIN WORDS · 2 in this section
snapshots
records of how things stood at one moment
github
a web site that hosts code and runs checks

PICTURE IT

The picture is the one the lesson above opens with. The table below shows how each part of it matches the software.

THE REAL JOB A suitcase with a leave-behind list and correction slips.

  1. List
  2. Place
  3. Fix
Suitcase

HOW THE PICTURE MAPS

How each part of the picture matches the software
In the pictureIn the software
The list on the doorThe ignore file
Taking a thing out of the open casegit restore
Taking it out of the closed casegit restore --staged
A correction slip after the trip startsgit revert

WHERE THIS PICTURE STOPS

  • A list stops packing, but an ignore rule never removes a tracked file.
  • A slip is paper, but a revert is a commit.
  • You can see inside a case, but you need git status to see Git.

HOOK

Find the place, then fix.

TELL A FRIEND

A suitcase: list, place, slip.

OFTEN MIXED UP WITH Git merge conflicts: read the markers, fix the file, finish the merge. That topic fixes a clash. This one keeps files out and undoes slips.

Sources & standards — 4 sources
  1. Market practice

    Git gitignore manual (2.51.0) ↗ — Git project · Git 2.51.0 — DESCRIPTION and NOTES: intentionally untracked files; already tracked files unaffected; force-add override.

    DESCRIPTION and NOTES: intentionally untracked files; already tracked files unaffected; force-add override. · Checked 2026-11-07

    Selected publisher sections read for Testing Tools audit. Git 2.51.0. This is not live service testing or a full-publication certification.

  2. Market practice

    Git git-restore manual (2.51.0) ↗ — Git project · Git 2.51.0 — DESCRIPTION and examples: default index source, HEAD with --staged, explicit --source and worktree/index destinations.

    DESCRIPTION and examples: default index source, HEAD with --staged, explicit --source and worktree/index destinations. · Checked 2026-11-07

    Selected publisher sections read for Testing Tools audit. Git 2.51.0. This is not live service testing or a full-publication certification.

  3. Market practice

    Git git-revert manual (2.51.0) ↗ — Git project · Git 2.51.0 — DESCRIPTION: clean worktree and commits recording inverse changes; conflict handling.

    DESCRIPTION: clean worktree and commits recording inverse changes; conflict handling. · Checked 2026-11-07

    Selected publisher sections read for Testing Tools audit. Git 2.51.0. This is not live service testing or a full-publication certification.

  4. Market practice

    Git git-reset manual (2.51.0) ↗ — Git project · Git 2.51.0 — DESCRIPTION and --hard: branch/index/worktree state and loss of uncommitted content.

    DESCRIPTION and --hard: branch/index/worktree state and loss of uncommitted content. · Checked 2026-11-07

    Selected publisher sections read for Testing Tools audit. Git 2.51.0. This is not live service testing or a full-publication certification.

PRACTISE AND KEEP

Sources for this topic — 4 sources
  1. Market practice

    Git gitignore manual (2.51.0) ↗ — Git project · Git 2.51.0 — DESCRIPTION and NOTES: intentionally untracked files; already tracked files unaffected; force-add override.

    DESCRIPTION and NOTES: intentionally untracked files; already tracked files unaffected; force-add override. · Checked 2026-11-07

    Selected publisher sections read for Testing Tools audit. Git 2.51.0. This is not live service testing or a full-publication certification.

  2. Market practice

    Git git-restore manual (2.51.0) ↗ — Git project · Git 2.51.0 — DESCRIPTION and examples: default index source, HEAD with --staged, explicit --source and worktree/index destinations.

    DESCRIPTION and examples: default index source, HEAD with --staged, explicit --source and worktree/index destinations. · Checked 2026-11-07

    Selected publisher sections read for Testing Tools audit. Git 2.51.0. This is not live service testing or a full-publication certification.

  3. Market practice

    Git git-revert manual (2.51.0) ↗ — Git project · Git 2.51.0 — DESCRIPTION: clean worktree and commits recording inverse changes; conflict handling.

    DESCRIPTION: clean worktree and commits recording inverse changes; conflict handling. · Checked 2026-11-07

    Selected publisher sections read for Testing Tools audit. Git 2.51.0. This is not live service testing or a full-publication certification.

  4. Market practice

    Git git-reset manual (2.51.0) ↗ — Git project · Git 2.51.0 — DESCRIPTION and --hard: branch/index/worktree state and loss of uncommitted content.

    DESCRIPTION and --hard: branch/index/worktree state and loss of uncommitted content. · Checked 2026-11-07

    Selected publisher sections read for Testing Tools audit. Git 2.51.0. This is not live service testing or a full-publication certification.

Deepest material on this page: L4 — Standards & sources. Where a topic stops short of implementation depth, that is a deliberate coverage decision, not an oversight — see coverage.