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 lineThe 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-loansA .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.