Skip to the workspace
Pebellslearn by building
General Development Skills  ›  Lesson

Git — Snapshots You Can Return To

Git - Version Control 13 minGit records your project as a chain of commits, and branches let you try changes safely before merging them back.

aspnet core / Git — Snapshots You Can Return To

Explore each scene at your own pace.

01 · The rule

The rule

Git — Snapshots You Can Return To

You change three files in ReadingRoom, and suddenly nothing starts. Which change broke it? Without version control you guess. With Git you ask for the difference against the last working version and see it line by line.

The rule

Stage what you mean, commit a snapshot, branch before you experiment.

Git keeps your project's history as a chain of commits. Each commit is a snapshot of the tracked files plus a message saying why it changed.

git init                        # start tracking this folder
git status                      # what changed since the last commit?
git add Program.cs              # stage: choose what goes in the next commit
git commit -m "Add GET /books"  # record the snapshot
git log --oneline               # list the history
git diff                        # show unstaged changes line by line

The staging area sits between your files and the history, so one commit can hold exactly the change you intended and nothing else.

A branch is a movable name pointing at a commit. main holds the working version. To try something, make a new branch; your commits move only that branch. When it works, merge it back.

git switch -c add-loans   # create a branch and move onto it
# ...edit, add, commit...
git switch main
git merge add-loans

A .gitignore file lists what Git should never track. For .NET that is the bin/ and obj/ build folders and local secrets. dotnet new gitignore writes a ready-made one.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.