← From Zero to Deployed Alle LektionenAll lessons Setup ModelleModels

Phase 1 · Grundlagen

11 · Git

Du verstehst, was Git tut und warum ein Agent ohne Git gefährlich ist.

Phase 1 · Foundations

11 · Git

You understand what Git does and why an agent without Git is dangerous.

Ein Coding-Agent macht schnell viele Änderungen. Git ist dein Sicherheitsnetz: Hat etwas funktioniert, hältst du es fest; hat etwas kaputtgemacht, springst du zurück. Ohne Git baust du ohne Rücksprungpunkt — das ist riskant.

Die Idee

Git ist eine Zeitmaschine für deine Dateien. Es macht Schnappschüsse. Ging etwas schief, springst du zum letzten guten Schnappschuss zurück. Nichts geht verloren.

Stell dir vor, du baust am Instagram-Feed. Du fügst einen Like-Button hinzu, alles klappt — Schnappschuss. Dann probierst du Kommentare aus, es zerlegt den Feed — kein Problem, du springst zum Schnappschuss mit dem funktionierenden Like-Button zurück.

So funktioniert es

Drei Begriffe:

Der Alltag als Befehle:

git init                       # Projekt unter Versionskontrolle stellen
git add .                      # Änderungen vormerken
git commit -m "Like-Button"    # Schnappschuss mit Nachricht
git branch kommentare          # Zweig zum Ausprobieren
git push                       # zu GitHub hochladen
gitGraph
    commit id: "Feed zeigt Beiträge"
    branch like-button
    commit id: "Like-Button"
    checkout main
    merge like-button
    commit id: "Live gestellt"

So steuerst du es

Git ist eine verteilte Versionsverwaltung: Die Historie ist eine Kette von Commits, jeder mit eindeutiger ID. Branches sind billige Zeiger; ein Merge führt Zweige zusammen. remote synchronisiert per push/pull.

Warum das mit Agenten wichtig ist: Committe kleine, funktionierende Schritte und prüfe den Diff (die Änderung), bevor du committest.

So sagst du es dem Agenten:

„Committe nach jedem funktionierenden Schritt mit einer kurzen, klaren Nachricht.“

„Zeig mir den Diff, bevor wir committen — ich will die Änderung prüfen.“

„Lege eine .gitignore an, die .env und node_modules ausschließt.“

Typische Fehler: Agentenänderungen blind und in Riesenpaketen committen (dann findest du den Fehler nicht mehr); Geheimnisse committen; oder ohne Git arbeiten und einen guten Stand nicht mehr zurückholen können.

Kurz-Check

  1. Was ist ein Commit?
  2. Wofür ist ein Branch da?
  3. Warum ist Git beim Bauen mit einem Agenten so wichtig?
Antworten anzeigen
  1. Ein gespeicherter Schnappschuss des Projekts mit kurzer Nachricht.
  2. Zum gefahrlosen Ausprobieren in einer Parallelkopie, ohne die funktionierende Version zu berühren.
  3. Er gibt Rücksprungpunkte: gute Schritte festhalten, schlechte rückgängig machen — bei vielen schnellen Änderungen unverzichtbar.

A coding agent makes many changes quickly. Git is your safety net: when something worked, you lock it in; when something broke it, you jump back. Without Git you build with no restore point — that is risky.

The idea

Git is a time machine for your files. It takes snapshots. If something goes wrong, you jump back to the last good snapshot. Nothing is lost.

Imagine you are building the Instagram feed. You add a like button, it all works — snapshot. Then you try comments, and it breaks the feed — no problem, you jump back to the snapshot with the working like button.

How it works

Three terms:

The daily rhythm as commands:

git init                       # put the project under version control
git add .                      # stage changes
git commit -m "Like button"    # snapshot with a message
git branch comments            # a branch to experiment
git push                       # upload to GitHub
gitGraph
    commit id: "Feed shows posts"
    branch like-button
    commit id: "Like button"
    checkout main
    merge like-button
    commit id: "Deployed"

How you steer it

Git is distributed version control: the history is a chain of commits, each with a unique id. Branches are cheap pointers; a merge joins branches. remote syncs via push/pull.

Why this matters with agents: commit small, working steps and review the diff (the change) before you commit.

How to tell the agent:

"Commit after each working step with a short, clear message."

"Show me the diff before we commit — I want to review the change."

"Create a .gitignore that excludes .env and node_modules."

Common mistakes: committing agent changes blindly in huge batches (then you cannot find the bug); committing secrets; or working without Git and being unable to recover a good state.

Quick check

  1. What is a commit?
  2. What is a branch for?
  3. Why is Git so important when building with an agent?
Show answers
  1. A saved snapshot of the project with a short message.
  2. For safe experimentation in a parallel copy without touching the working version.
  3. It provides restore points: lock in good steps, undo bad ones — indispensable with many fast changes.